Here there is an answer on how to expand a subgrid when we click a row using:
onSelectRow: function(rowId) {
$("#jqgrid_id").expandSubGridRow(rowId);
}
How can we collapse the row if it has been already expanded? I am looking for something like:
onSelectRow: function(rowId){
if (the_row_of_the_grid is expanded) {
// collapse: How implement this???
} else {
$("#jqgrid_id").expandSubGridRow(rowId);
}
}
to have a complete expand/collapse on row click.
I haven't tested it, but it seems to me that the following code should do what you need:
onSelectRow: function (rowId) {
$("#jqgrid_id").jqGrid ('toggleSubGridRow', rowId);
}
(see jqGrid documentation)