Closed sigoofballde closed 6 years ago
Sorry, but it's difficult to help you without to see any JavaScript code. Please post always the demo (in JSFiddle for example), which can be used to reproduce the problem, which your reports.
I suppose that you save/restore the order of the columns in the wrong way. During saving the order of columns I'd recommend you to save the names of columns and no indexes of columns. During restoring the column order I'd recommend to use remapColumnsByName
method instead of old remapColumns
method. You can find an example of the corresponding code in the answer.
Thanks Oleg, this worked for me. Was exactly what I needed.
I am saving a column model so users can save their column order among other things. When I give this column model to jqgrid, it moves the correct columns, but then it also moves 1 other column for each column that has been moved.
Example: I move 1 column called "from6A" from the middle of the columns to be the first column. Everything looks fine, when I save that column model it is saved correctly. I leave that page and come back in, the column model I provide to jqgrid is the correctly saved one with "from6A" at the beginning of the column order. When jqgrid loads the table, "from6A" is now the second column from the beginning, with another column "sortcol_8A" in front of it that shouldn't be.
There are other columns at the beginning that jqgrid adds, like row numbers and stuff like that, but those are expected. This one from the middle of the columns is not. In the pictures I am adding I moved 3 columns, easier to see what is going on.
Original Column Model:
Saved Column Model (what it should look like):
What jqgrid loads (Columns that shouldn't be moved in orange):