开发者

Change the Sequence of JqGrid Columns

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

bu开发者_开发百科t I could not get this work.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜