问题
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:
- I filtered the Client grid by the
client_name
field inasc
order. - I then clicked a link which takes me to a separate page with a new grid.
- I want to navigate back to the Client grid I was previously on, seeing my grid with
client_name
filtered inasc
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