【发布时间】:2013-02-02 05:41:38
【问题描述】:
我有从 json 服务读取数据的 jqgrid
$('#list').jqGrid({
url: 'jsonservice',
datatype: 'json',
mtype: 'GET',
colNames: ['Id', 'Name', 'Street', 'City'],
colModel: [
{ name: 'Id', index: 'Id', width: 55, align: 'center', width: '25' }
{ name: 'Name', index: 'Name', width: 120 },
{ name: 'Street', index: 'Street', width: 90 },
{ name: 'City', index: 'City', width: 50 },
]
});
json 服务返回这样的数据
{"page":1,
"total":37,
"records":722,
"rows":
[
{"id":1,"cell":[1, "Sample name 1","Sample Street 2","Sample City 3"]},
{"id":2,"cell":[2, "Sample name 2","Sample Street 2","Sample City 3"]}
]
}
如何将显示列的顺序更改为例如名称、城市、街道、ID 不改变 json 数据中的顺序?
【问题讨论】:
-
我试过了,但我找不到如何改变它。我发现只有函数 remapColumns 不能按我的意愿工作
-
我通过函数 remapColumns 资助了一种方法,例如$('#list').remapColumns([1,3,2,0], true, false]);但是当你有额外的列时应该小心,例如rownumbers: true 或 subgrid 展开列。此列也可以重新排序。
标签: jqgrid