Disable sorting in jqGrid
Asked Answered
B

2

12

Is it possible to disable sorting in jqGrid for all columns instead of adding sortable: false to each column in colModel?

Bootie answered 22/8, 2011 at 13:17 Comment(0)
C
20

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.

Cub answered 22/8, 2011 at 13:53 Comment(1)
I wanted to write the same. Thanks! The feature cmTemplate exists already in jqGrid 3.8.2, but the priority of cmTemplate was too high in 3.8.2. So if you use cmTemplate: {sortable:false} and have sortable:true in some column, the jqGrid 3.8.2 will use sortable:false for all columns and jqGrid 4.x will do use the setting sortable:true for one column.Biological
P
1

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 });
        }
  }
Panter answered 26/11, 2013 at 17:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.