My jqgrid contains several pages. When I sort any column the page resets to first.
(That’s right also for filterToolbar i.e. after calling $(“#my-grid”)[0].triggerToolbar();)
Is there any way to keep my current page after sorting/filtering ?
EDIT:
Actually my problem is a little more complicated.
I save jqgrid preferences(rowNum, page, filters etc..) to the cookie.
When I load the page first time I load the prefs.
I use the technique from Mark B’s answer (see jqGrid Filter Toolbar initial default value) to populate my filter default values.
The problem: in that case page always sets to the first.(because of triggerToolbar calling) i.e. it doesn’t save state.
I don’t quite understand your requirement. If the user has seen some rows on the second page for example and then the user has clicked on the column header to sort the column the the grid will be sorted. The data which the user have seen before can be on any page. So I don’t understand why you want hold the current page which will show absolutely another data as it showed before.
If you do need to hold the page you can do this in the following way. Inside of the
loadCompleteyou can save the value ofpageparameter. Inside ofonSortColevent handler the value will be already changed to 1, but you can correct it to the value which you saved before. I didn’t tested this, but I think it should work.UPDATED: Now I think I understand your original problem. I think you should choose another way described here or here. What you needs is just to save in the cookie the
postDatavalue and to setsearch:trueparameter of jqGrid if thefiltersis not empty (or other filter parameter depend on the options which you use). In the way you should be able to restore not only the filter, but additionally thepagevalue. The final solution can a little depend from jqGrid parameters and the parameters offilterToolbarwhich you use. So it you will have implementation problem you should include more code which you use.