更改 JqGrid 列的顺序

发布于 2024-09-18 22:32:47 字数 514 浏览 3 评论 0原文

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

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

我尝试这样做:

{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},   
}

但我无法完成这项工作。

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?

I tried doing like:

{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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街道布景 2024-09-25 22:32:47

您可以使用remapColumns函数来执行此操作。在该函数的文档中,您将找到以下示例:似乎是错误的,因为排列数组中的索引似乎是从 1 开始的,而不是从 0 开始的。尝试使用:

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

或者

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

如果您想更改总共 9 列中第二列和第三列的顺序。

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

or

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文