If you use subgrid as grid you have to create new grid inside of subGridRowExpanded
callback. The callback get rowid
as a parameter. So if you would get the array of data which can be used as data
parameter of the subgrid the subgrid can be defined with datatype: 'local'
.
The code schema can be about the following:
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],
...
});
});