3
votes

I delete a row in a jqGrid like so:

elem.jqGrid('delRowData', rowid);

But the subgrid associated to this row remains. What other clever thing do I need to do to make the whole row (including subgrid) go away?

2

2 Answers

5
votes

You can do instead of the code which you posted the following:

var selRow = $('#'+rowid),   // get the row (<tr> element having id=rowid)
    nextRow = selRow.next(); // get the next row

if (nextRow.hasClass('ui-subgrid')) {
    // if the next row is a subgrid one should remove it
    nextRow.remove();
}
elem.jqGrid('delRowData', rowid);
// the call of delRowData is better as just selRow.remove();
// because it change "records" and "reccount" parameters and 
// change parameters "selrow" and "selarrrow" in case that
// the deleted row was selected.
2
votes

This seems to work:

elem.jqGrid('collapseSubGridRow', rowid);
elem.jqGrid('delRowData', rowid);

Umm, okay.