Is it possible to disable sorting in jqGrid for all columns instead of adding sortable: false
to each column in colModel?
Disable sorting in jqGrid
This functionality was added in jqGrid 4.0+
After defining your colModel section in the jqGrid configuration, add the following:
cmTemplate: {sortable:false},
This will force all columns to no longer be sortable.
If you want to conditionally disable sorting on all columns rather than hardcoding it in your grid then I would recommend the following
//your function
function Example(){
//define grid
var grid = $("#list");
//get all column names
var columnNames = grid[0].p.colNames;
//iterate through each and disable
for (i = 0; i < columnNames.length; i++) {
grid.setColProp(columnNames[i], { sortable: false });
}
}
© 2022 - 2024 — McMap. All rights reserved.
cmTemplate
exists already in jqGrid 3.8.2, but the priority ofcmTemplate
was too high in 3.8.2. So if you usecmTemplate: {sortable:false}
and havesortable:true
in some column, the jqGrid 3.8.2 will usesortable:false
for all columns and jqGrid 4.x will do use the settingsortable:true
for one column. – Biological