jqGrid: Disable sorting

六眼飞鱼酱① 提交于 2019-12-20 17:26:20

问题


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
});

回答1:


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




回答2:


Depending on the jqGrid version you need to make sortable: false on each column specifically + explicitly...

For references see here, here and here.



来源:https://stackoverflow.com/questions/8126712/jqgrid-disable-sorting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!