Hazem Salama
Hazem Salama

Reputation: 15101

Dynamically enable grouping in jqGrid

I am trying to enable/disable grouping dynamically on a jqGrid on a button click, but it does not seem to be working. I am trying with this code but no luck

$('#mybutton').click(function(){
     $('#mygrid').jqGrid('setGridParam', { grouping:true });
});

The grouping is generated with the following

groupingView : { 
    groupField : ['product'], 
    groupColumnShow : [true], 
    groupText : ['<b>{0}</b>']
}

Thanks!

Upvotes: 3

Views: 5062

Answers (1)

Oleg
Oleg

Reputation: 221997

Grouping feature has some method which you could use: groupingRemove, groupingGroupBy, groupingToggle.

To remove the grouping you can use

grid.jqGrid('groupingRemove', true);

(where var grid = $('#list');). To enable grouping you can use the code like

grid.jqGrid('groupingGroupBy',['product']);

or for example

grid.jqGrid(
    'groupingGroupBy',
    ['product'],
    { groupText: ['<b>Product(s): "{0}" - {1} item(s)</b>'] }
);

Upvotes: 3

Related Questions