开发者

jqGrid - groupCollapse on init but after search unCollapse

I have a jqGrid that is using the toolbar search with some text searches for businessName and a dropdown for states. I am using the grouping feature to group by state and this works great. I have also set t开发者_开发问答he option of groupCollapse to true so basically loads a grid of states with their count of businesses.

groupText: ["{0} - {1} businesses"],
groupCollapse:true

Then for my toolbar search bar filterToolbar

$("#businessGrid").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false, 
    afterSearch : function(){
   $("#businessGrid").jqGrid('setGridParam', 
          {'groupCollapse':false}
      ).trigger('reloadGrid');
      var x = $("#businessGrid").jqGrid('getGridParam','groupCollapse');
      console.log(x);
    }

});

When I log [ x ] it is indeed setting the gridParam to false but when I trigger a reload of the grid it doesn't un-collapse the groups.

Any ideas would be appreciated. If its not possible I'll have to come up with a different solution, but this behavior would be ideal.

Thanks, Tim


think i found the solution removes the grouping which is fine since only one state can be chosen at once any way.

///if blank option (all states option) is chosen reapply grouping 
if($("#gs_StateFull").val() == "") {
   $("#businessGrid").jqGrid('setGridParam',{'grouping':true}).trigger('reloadGrid');
} else {
   $("#businessGrid").jqGrid('setGridParam',{'grouping':false}).trigger('reloadGrid');  

}

EDIT: Since groupCollapse inside the groupingView object it needed to be set using the syntax below. THis keeps the grouping intact as well

///if blank option (all states option) is chosen reapply grouping 
if($("#gs_StateFull").val() == "") {
   $("#businessGrid").jqGrid('setGridParam',{groupingView: { groupCollapse : true} }).trigger('reloadGrid');
} else {
   $("#businessGrid").jqGrid('setGridParam',{groupingView: { groupCollapse : false} }).trigger('reloadGrid');   

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜