Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify default filter in jqgrid

Tags:

jqgrid

I want to preload a set of filters on initial load of the grid. The reason for this is that I am planning to store the last selected filter in a session variable so the user will come back to the grid as he left it the last time.

I know there is an option to set defaultValue under editoptions for one column, but I am looking for a way to load the whole filter at once. (Not a function for each coulmn).

like image 509
ffffff01 Avatar asked Feb 13 '12 17:02

ffffff01


Video Answer


2 Answers

I suppose that you use advanced searching for the filtering. The filter is nothing more as the value of postData.filters. See here and the demo from another old answer for details.

Moreover I would recommend you to read the demo where I describe how to use localStorage to save some user preferences of the grid inclusive the searching filter. Moreover I describe why I think the usage of the localStorage the better way as the usage of cookies or session variables.

like image 133
Oleg Avatar answered Oct 15 '22 22:10

Oleg


In the column options, add the defaultValue parameter inside the searchoptions option:

searchoptions:{ sopt:['eq'], defaultValue:"SomeValue" }
like image 44
Justin Levene Avatar answered Oct 15 '22 23:10

Justin Levene