Is there anyway I can enable or disable column sorting during runtime?
I can remove or add the class that makes sorting possible, and when I remove it the column can't be sorted. But when I restore it the grid sorts that column automatically as if someone had sorted it.
Yes, you can.
Let's write some context:
//Here you have your grid.
jQuery('#myGrid');
//Here the definition of a colModel
{name:'Name', index:'name', sortable:true, align:'left', required: true, editable:true, edittype:'text'}
And now, when you click on some button you call a function, which is supposed to disable sorting from the column Name. This is what the function should look like.
function disableSorting(){
jQuery('#myGrid').setColProp('Name', {sortable: false});
}
Tested and it works :)
$("#jqGrid").jqGrid({
colModel: [ { label: 'Category Name', name: 'CategoryName', width: 75, **sortable: false** }]
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With