更改JqGrid列的顺序 [英] Change the Sequence of JqGrid Columns

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

问题描述

我想动态更改网格列的顺序.例如默认情况下,网格将以LoginId,FirstName和LastName顺序加载.根据某些条件,我需要更改名字和姓氏的顺序.

I wanted to change the grid column sequence dynamically. For e.g. By default the grid will be loaded in LoginId, FirstName and LastName sequence. Based on some condition, I need to change the FirstName and LastName sequence.

有什么办法可以做到这一点?

Is there any way I can do this?

我尝试这样做:

{name:'UserName',index:'UserName',width:82,sortable:false},
if(true)
{
   {name:'FirstName',index:'FirstName',width:65,sortable:false},
   {name:'LastName',index:'LastName',width:65,sortable:false},
}
else
{
   {name:'LastName',index:'LastName',width:65,sortable:false},
   {name:'FirstName',index:'FirstName',width:65,sortable:false},   
}

但我无法完成这项工作.

but I could not get this work.

推荐答案

您可以使用remapColumns函数执行此操作.在该函数的文档中,您会找到以下示例似乎是错误的,因为置换数组中的索引似乎是基于1的,而不是基于0的.尝试使用:

You can use remapColumns function to do this. In the documentation of the function you will find the example which seems to be wrong, because indexes in the permutation array seem to be 1-based and not 0-based. Try to use:

$("#list").remapColumns([1,3,2],true,false);

$("#list").remapColumns([1,3,2,4,5,6,7,8,9],true,false);

如果要更改总9列中第二和第三的顺序.

if you want to change the order of the second and third from the total 9 columns.

这篇关于更改JqGrid列的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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