How To Show Jqgrid Subgrid On Certain Rows Only?
Solution 1:
If I correctly understand your question then you want to remove "+" (expand subgrid) icon for rows which have no elements in the subgrid. In the case you can follow the old trick described in the old answer. You can add loadComplete
handle which removes some "+" icons from the grid having subGrid: true
option. You need just know rowids of all rows of the grid which have no subgrid and do for the rows
$("#" + rowid + ">td.sgcollapsed").unbind("click").html("");
UPDATED: I posted the modification of free jqGrid which allows easy implement the requirement without the above hack.
The demo demonstrates the new feature. The implementation is very easy. It contains hasSubgrid
callback inside of subGridOptions
. The callback have options
which is object with the properties rowid
, data
and two less important properties iRow
and iCol
. The code of the demo uses options.data
which represent the data of the row. The demo creates subgrid only if input row have tax
higher as 20.
subGridOptions: {
hasSubgrid: function (options) {
returnparseFloat(options.data.tax) > 20;
}
}
You can use mySubgrids[options.data.rowid].length
in your case, if I correctly understand the format of your input data.
Post a Comment for "How To Show Jqgrid Subgrid On Certain Rows Only?"