I’ve a jqGrid-based application, and I use loadonce: true in the grid option and sortable: true, sorttype: 'text in the colModel to allow client-side sorting on the data grid. However, I found that, once the data grid is re-sorted, the last selected row will no longer be highlighted. My question is, how to keep the selected row being highlighted across data resorting?
I’ve a jqGrid-based application, and I use loadonce: true in the grid option and
Share
I prepared for you the small demo which keeps the row selection. In the demo I rewrote the code of selectionPreserver used in case of reloadGrid usage having additional parameters:
$("#list").trigger("reloadGrid", [{current:true}]);. See the answer for details.The demo saves the current selection inside of the
onSortColevent handler and restore it inside of theloadComplete:How you see the usage is very simple and you can integrate it in your code. The implementation of the
saveSelectionandrestoreSelectionis the following: