How to load subseries statically?

I do not want to use ajax to load data in my grid. Is there a way to load all the data into the main grid and subgrids statically?

subGridUrl from the jqGrid documentation require the subGridUrl parameter. But I want something like:

 var mydata = [ { // ... some static code for data creation here } ] 

and using mydata in the data parameter, but subGrid does not have this parameter or anything else.

0
javascript jqgrid subgrid
Feb 06 '12 at 17:55
source share
1 answer

If you use subgrid as a grid , you need to create a new grid inside the subGridRowExpanded . The callback receives rowid as a parameter. Therefore, if you get an array of data that can be used as the data parameter for the subnet, the subgrade can be defined using datatype: 'local' .

The code diagram might be something like this:

 var mainGridData = [ {id: 'm1', ...}, {id: 'm2', ...}, ], subgridData1 = [ {id: 's11', ...}, {id: 's12', ...}, ], subgridData2 = [ {id: 's21', ...}, {id: 's22', ...}, ], subgridByMainGridId = { m1: subgridData1, m2: subgridData2 }; $('#mainGrid').jqGrid({ datatype: 'local', data: mainGridData, .... subGrid: true, subGridRowExpanded: function(subgridId, rowId) { var subgridTableId = subgridId + "_t"; $("#" + $.jgrid.jqID(subgridId)).html('<table id="' + subgridTableId + '"></table>'); $("#" + $.jgrid.jqID(subgridTableId)).jqGrid({ datatype: 'local', data: subgridByMainGridId[rowId], ... }); }); 
+2
Feb 06 '12 at 19:27
source share



All Articles