$("#grid").jqGrid({
datatype: 'local',
data: myGridData,
colNames: ['id','Column 1', 'Column 2'],
colModel: [
{ name: 'id', hidden: true, key: true},
{ name: 'col1', width: 200 },
{ name: 'col2', width: 200 }
],
subGrid: true,
height: 400,
subGridBeforeExpand: function(pID, id) {
if(last_expanded_row_id !== undefined) {
setTimeout(function() {
$("#grid").collapseSubGridRow(last_expanded_row_id);
}, 50);
}
},
subGridRowExpanded: function (pID, id) {
var childGridID = pID + "_table";
var childGridPagerID = pID + "_pager";
$('#' + pID).append('<table id=' + childGridID + '></table><div id=' + childGridPagerID + ' class=scroll></div>');
$("#" + childGridID).jqGrid({
datatype: 'local',
data: mySubgrids[id],
colNames: ['Col 1', 'Col 2', 'Col 3'],
colModel: [
{ name: 'c1', width: 100 },
{ name: 'c2', width: 100 },
{ name: 'c3', width: 100 }
],
gridComplete : function() {
setTimeout(function() { last_expanded_row_id = id;},1000);
}
});
}
});