Expanding jqgrid subgrid
Asked Answered
I

2

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.

Incidence answered 27/7, 2010 at 15:46 Comment(0)
N
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); 
      });
   },
...
});
Nobility answered 27/7, 2010 at 15:57 Comment(5)
Can I expand the subgrid without the user having to click on anything? For example, after the jqgrid and subgrid have finished loading, the subgrid is automatically expanded.Incidence
sure in that case use the onGridComplete Event.Nobility
What would I use for the rowID?Incidence
Sorry trevor. Probably should have been more specific. Check out my edited answerNobility
AS mentioned by @Stefan below, Change getDataIds() to getDataIDs()!Lickerish
C
1

Change getDataIds() to getDataIDs()!

Calycle answered 26/8, 2010 at 19:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.