Disable sorting in jqGrid
Is it possible to disable sorting in jqGrid for all columns instead of 开发者_C百科adding sortable: false
to each column in colModel?
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 });
}
}
精彩评论