I combined the code of the previous answer about preserving the preferences of the jqGrid column with the code from another answer where I proposed code that implemented a constant selection of rows. It is important to note that in the case of multiselect:true it will use an array of identifiers for the selected lines, which contains all the selected ones, even if the lines are on another page. This is very practical and the implementation is very simple. Therefore, I posted the corresponding function request , but it still remains unanswered.
Now I can present two demos: the first demo that uses multiselect: true and the second demo that uses the same code, but with a single choice.
The most important parts of the code that I used are found below.
It is very important to mention: you must change the value of myColumnStateName on every page that you use . The value of the variable contains the name of the column state in localStorage . Thus, you will not change the name in which you share the state of different tables, which can lead to very strange consequences. You can use names created from the name of the current page or URL as the value of myColumnStateName .
var $grid = $("#list"), getColumnIndex = function (grid, columnIndex) { var cm = grid.jqGrid('getGridParam', 'colModel'), i, l = cm.length; for (i = 0; i < l; i++) { if ((cm[i].index || cm[i].name) === columnIndex) { return i;
UPDATED . I forgot to mention that when using the multiselect: true option with jqGrid 4.3 it is very important to use the fix described here. In the first demo, I used a modified version of jquery.jqGrid.src.js that includes error correction.
UPDATED 2 . To simplify the creation of a unique name for the local storage element used to save the state of the grid, I modified the demo a bit. The next version is a multi-selector demo and a single selection demo, use myColumnStateName as a function defined as
var myColumnStateName = function (grid) { return window.location.pathname + '#' + grid[0].id; }
The use of myColumnStateName changes accordingly. In addition, I expanded the state of the column to preserve the value of rowNum .
UPDATED 3: The answer describes how you can use the new free jqGrid feature to save the state of the grid.