7

I have a jqgrid that has a subgrid. How can I expand the subgrid without having to click on the plus sign?

I came across $("#jqgrid_id").expandSubGridRow(rowId); but am unsure which rowId to use to expand the subgrid.

Thanks.

Oleg
  • 220,925
  • 34
  • 403
  • 798
Trevor
  • 6,659
  • 5
  • 35
  • 68

2 Answers2

11

Use $("#jqgrid_id").expandSubGridRow(rowId); in the onSelectRow Event of the grid.

Something like this:

jQuery("#jqgrid_id").jqGrid({
...
   onSelectRow: function(rowId){ 
      $("#jqgrid_id").expandSubGridRow(rowId); 
   },
...
});

EDITED: on GridComplete event

jQuery("#jqgrid_id").jqGrid({
...
   gridComplete: function(){ 
      var rowIds = $("#jqgrid_id").getDataIDs();
      $.each(rowIds, function (index, rowId) {
        $("#jqgrid_id").expandSubGridRow(rowId); 
      });
   },
...
});
John Hartsock
  • 85,422
  • 23
  • 131
  • 146
1

Change getDataIds() to getDataIDs()!

Stefan
  • 11
  • 1