问题描述
有没有办法使网格上的所有列不可排序,除了向每列添加 sortable:false
?我知道你可以在网格级设置全局选项,但不知道你是否可以在colModel级别做。
在jqGrid中没有与 colModel
中的 sortable:false
对应的全局设置。此外,jqGrid读取直接 colModel
的值,而不使用每个列元素的一些默认设置。因此,您必须在每个列中明确定义 sortable:false
。
另一方面,您可以执行以下操作:
//我们定义简化的列模型,而不重复相同的信息
var cm = [
{ name:'id',key:true},
{name:'name'},
// ...
];
// new我们定义我们的标准属性,它将在所有列中相同
var myStdModel = {width:150,sortable:false};
//我们扩展(或覆盖)我们的标准属性
for(var i = 0; i $ .extend ,myStdModel);
cm.index = cm.name;
}
$(#list)。jqGrid({
colModel:cm,//我们使用之前建立的列模型
//所有其他设置
});
在这种方式下,你可以存档你想要的相同结果, / p>
Is there a way to make all columns on a grid NOT sortable other than adding sortable:false
to each column? I know you can set global options at the grid level but didn't know if you could do it at the colModel level.
There are no global setting in jqGrid which corresponds to the sortable:false
from the colModel
. Moreover jqGrid read directly the value of colModel
without usage some default setting per every column element. So you have to define sortable:false
in every column explicitly.
On the other side you can do following:
// we define simplified column model without repeating of the same information
var cm = [
{name:'id', key: true},
{name:'name'},
// ...
];
// new we define "our standard" properties which will be the same in all columns
var myStdModel = {width: 150, sortable: false};
// we extend (or overwrite) "our standard" properties
for (var i=0; i<cm.length; i++) {
$.extend(cm, myStdModel);
cm.index = cm.name;
}
$("#list").jqGrid ({
colModel: cm, // we use the column model built before
// all other settings
});
In the way you can probably archive the same results which you want, but in the other way.
这篇关于jqGrid - 使所有列不可排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!