Expanding jqgrid subgrid

2019-03-20 06:12发布

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.

2条回答
放我归山
2楼-- · 2019-03-20 06:45

Change getDataIds() to getDataIDs()!

查看更多
倾城 Initia
3楼-- · 2019-03-20 07:03

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); 
      });
   },
...
});
查看更多
登录 后发表回答