Wie wird das jqGrid-Teilgitter nur in bestimmten Zeilen angezeigt? [Duplikat
Diese Frage hat hier bereits eine Antwort:
Hide expand / collapse symbol oder deaktiviere spec. Zeilen in jqGrid subgrid 1 AntwortIch habe mit @ ein Raster mit mehreren Teilrasterebenen erstell jqGrid und mit ein wenig hilfe von diesemAntworte. Folgendes habe ich derzeit:
Ich versuche, es so zu ändern, dass das Sub-Grid nur angezeigt wird, wenn Daten angezeigt werden. Mit anderen Worten, wenn dascount > 0
. Logischerweise habe ich versucht, eine Bedingung hinzuzufügen (Pseudocode unten, basierend auf der zuvor genannten Antwort):
Original Code
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);
Angepasster Code
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);
aber das scheitert nur kläglich:
Wird dies einfach nicht unterstützt oder mache ich etwas falsch?