Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid: Disable sorting

Tags:

I am adding rows manually to jqGrid using addRowData, and the order of these rows must be maintained.

However, when paging, all rows are reordered to sort by the grid's first visible column.

I have turned off all sorting options that I can find documented.

How can I prevent all sorting and maintain the order of rows across all pages?

Code

Initialization code being used:

$("#grid").jqGrid({   autowidth: false,   cmTemplate: {sortable: false},   colModel: config.gridColumnModel   height: 600,   pager: "#aggregationToolbar",   sortable: false,   shrinkToFit: false   url: "fetch",   viewrecords: false }); 

Default settings being used (overridden by the options in the initialization code above):

$.extend($.jgrid.defaults, {   altClass: "altRow",   altRows: true,   autowidth: true,   cmTemplate: {     align: "center",     title: false   },   datatype: "local",   gridview: true,   height: "auto",   hidegrid: false,   jsonReader: {     page: function(obj) { return 1; },     records: function(obj) { return obj.length; },     repeatitems: false,     root: "objects",     total: function(obj) { return 1; }   },   loadonce: true,   rowList: [50, 100, 250],   rowNum: 100,   sortable: true,   toppager: true,   viewrecords: true }); 
like image 929
Donald Taylor Avatar asked Nov 14 '11 19:11

Donald Taylor


People also ask

How to remove sorting in jqGrid?

To enable or disable the sorting of a Grid column, you can set its sortable property to false. In the code example below, the sorting of the "ShipName" column is disabled. });

How do I sort a column in jqGrid?

The value of sidx parameter will be constructed from sortname option of jqGrid and the value of sord from sortorder . So you should do the following: $('#yourgrid'). jqGrid('setGridParam', {sortname: 'yourColumn', sortorder: 'asc'}).


1 Answers

For versions that support cmTemplate, you can use:

cmTemplate: { sortable: false }


cmTemplate: Defines a set of properties which override the default values in colModel. For example if you want to make all columns not sortable, then only one propery here can be specified instead of specifying it in all columns in colModel

like image 110
Pat Newell Avatar answered Oct 21 '22 04:10

Pat Newell