Como mostrar a subgrid jqGrid apenas em determinadas linhas? [duplicado]
Esta pergunta já tem uma resposta aqui:
Oculte o símbolo de expansão / recolhimento ou desative as especificações. linhas na sub-grade jqGrid 1 respostaCriei uma grade com vários níveis de sub-grade usandojqGrid e com uma pequena ajuda dissoresponda. Aqui está o que eu tenho atualmente:
Estou tentando modificá-lo de forma a mostrar apenas a sub-grade se houver dados para mostrar. Em outras palavras, se ocount > 0
. Logicamente, tentei adicionar uma condição (pseudo-código abaixo, com base na resposta mencionada anteriormente):
Código original
var gridParams = {
datatype: 'local',
data: myGridData,
colNames: ['Column 1', 'Column 2'],
colModel: [
{ name: 'col1', width: 200 },
{ name: 'col2', width: 200 }
],
...
subGrid: true,
subGridRowExpanded: function (subgridDivId, rowId) {
var subgridTableId = subgridDivId + "_t";
$("#" + subgridDivId).html("<table id='" + subgridTableId + "'></table>");
$("#" + subgridTableId).jqGrid({
datatype: 'local',
data: mySubgrids[rowId],
colNames: ['Col 1', 'Col 2', 'Col 3'],
colModel: [
{ name: 'c1', width: 100 },
{ name: 'c2', width: 100 },
{ name: 'c3', width: 100 }
],
...
});
}
}
$("#grid").jqGrid(gridParams);
Código ajustado
var gridParams = {
datatype: 'local',
data: myGridData,
colNames: ['Column 1', 'Column 2'],
colModel: [
{ name: 'col1', width: 200 },
{ name: 'col2', width: 200 }
],
...
}
// Condition added HERE
if (count > 0)
{
gridParams.subGrid = true;
gridParams.subGridRowExpanded = function (subgridDivId, rowId) {
var subgridTableId = subgridDivId + "_t";
$("#" + subgridDivId).html("<table id='" + subgridTableId + "'></table>");
$("#" + subgridTableId).jqGrid({
datatype: 'local',
data: mySubgrids[rowId],
colNames: ['Col 1', 'Col 2', 'Col 3'],
colModel: [
{ name: 'c1', width: 100 },
{ name: 'c2', width: 100 },
{ name: 'c3', width: 100 }
],
...
});
}
}
$("#grid").jqGrid(gridParams);
mas isso apenas falha miseravelmente:
Isso simplesmente não é suportado ou estou fazendo algo errado?