Javascript jqGrid:禁用排序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8126712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jqGrid: Disable sorting
提问by Donald Taylor
I am adding rows manually to jqGrid using addRowData
, and the order of these rows must be maintained.
我正在使用 手动向 jqGrid 添加行addRowData
,并且必须保持这些行的顺序。
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
});
采纳答案by Pat Newell
For versions that support cmTemplate
, you can use:
对于支持 的版本cmTemplate
,您可以使用:
cmTemplate: { sortable: false }
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
cmTemplate:定义一组覆盖 colModel 中默认值的属性。例如,如果你想让所有的列都不可排序,那么这里只能指定一个属性,而不是在 colModel 的所有列中都指定它