Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

but I could not get this work.

like image 342
Amar Avatar asked Feb 27 '23 07:02

Amar


1 Answers

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.

like image 193
Oleg Avatar answered Mar 30 '23 20:03

Oleg