JQGRID enable / disable column sorting

Anyway, can I enable or disable column sorting at runtime?

I can remove or add a class that makes sorting possible, and when I delete it, the column cannot be sorted. But when I restore it, the grid sorts this column automatically, as if someone had sorted it.

+5
source share
2 answers

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 that should disable sorting from the Name column. This is how the function should look.

function disableSorting(){
    jQuery('#myGrid').setColProp('Name', {sortable: false});
}

Tested and working :)

+13
source
$("#jqGrid").jqGrid({
    colModel: [ { label: 'Category Name', name: 'CategoryName', width: 75, **sortable: false** }]
});
+1
source

All Articles