var last_expanded_row_id;
$("#grid").jqGrid({
datatype: 'local',
data: myGridData,
colNames: ['Column 1', 'Column 2'],
colModel: [
{ name: 'col1', width: 200 },
{ name: 'col2', width: 200 }
],
...
subGrid: true,
subGridBeforeExpand: function(pID, id) {
if(last_expanded_row_id !== undefined) {
$("#grid").collapseSubGridRow(last_expanded_row_id);
}
},
subGridRowExpanded: function (pID, id) {
//here id receives incorrect row id.
$("#"+pID).html(pID+ "_t");
$("#"+pID+"_t").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 }
],
...
});
last_expanded_row_id = id;
}
});