Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically enable grouping in jqGrid

Tags:

jquery

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!

like image 983
Hazem Salama Avatar asked Dec 11 '25 15:12

Hazem Salama


1 Answers

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>'] }
);
like image 122
Oleg Avatar answered Dec 14 '25 05:12

Oleg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!