Get a Grid's Filter Parameters

戏子无情 提交于 2020-01-03 05:11:13

问题


I'm using jQGrid and I'm wondering if there is a way to get the current filters that have been applied to the grid I'm viewing. For example, if the grid has been sorted by a certain column (asc or desc), search parameters that may have been applied, etc.

Here is my problem: I would like to pass some parameters back to the previous grid I was viewing (or the last page) so that I can see the previous grid as it was when I navigated forward. Basically, I have a link the user will click which navigates back to the page with the previous grid they were viewing. I want to pass the filter parameters along with that link.

Overall Example:

  1. I filtered the Client grid by the client_name field in asc order.
  2. I then clicked a link which takes me to a separate page with a new grid.
  3. I want to navigate back to the Client grid I was previously on, seeing my grid with client_name filtered in asc order as it was when I had navigated away the first time.

Currently, I am able to navigate back to the Clients grid but I would like to get the filter parameters that had been applied so I can pass them with my link back.

Let me know if I'm being specific enough!

Thanks for the help!


回答1:


I would recommend to read the answer and this one. The answers shows how to solve very close problem by the usage of window.localStorage. The most important options of jqGrid which defines the state are: sortname, sortorder for sorting, search and postData (mostly postData.filters) for filtering, page for paging. Moreover if you use columnChooser you would need to use remapColumns option of jqGrid. You can include additionally take in consideration the information about current selected row/rows (selrow or selarrrow). So the exact list of the parameters which you need save or restore depends on your requirements.



来源:https://stackoverflow.com/questions/11216815/get-a-grids-filter-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!