jqGrid:禁用排序 [英] jqGrid: Disable sorting

查看:748
本文介绍了jqGrid:禁用排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 addRowData 手动向jqGrid添加行,并且必须维护这些行的顺序。

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?

代码

正在使用的初始化代码:

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


推荐答案

对于支持 cmTemplate的版本,您可以使用:

For versions that support cmTemplate, you can use:

cmTemplate:{sortable:false}

cmTemplate :定义一组覆盖colModel中默认值的属性。例如,如果您想使所有列都不可排序,那么此处只能指定一个属性而不是在colModel的所有列中指定它

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

这篇关于jqGrid:禁用排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆