问题
i want to automate a user going into the "Find Records" / multi search UI and preset a filter in jqgrid to
Specific field contains "abc"
Second field does not equal "123"
is this possible in jqgrid? i can set the toolbar filter by just adding item to the query string (Field1="test") so, in my asp.net-mvc controller action, i would do something like this:
string name = "Joe";
return Redirect("/Project?Owner=" + name);
but i now want to replicate the support for the advanced search so i can do
- Multiple Fields
Different operator (equals, does not equal)
i would like it to work so if the user did click on the Filter button that it would be prepopualated with these filter just like as if they would have done this initial filter manually like this:
I see this question but i want to be able to do this from the server side. Is there anyway to set postdata from the serverside of any asp.net mvc app??
回答1:
Presetting of the filter is nothing more as setting pf postData
jqGrid parameter. See the old demo (see the answer). If one set search:true
the filter will apply (see here and here).
Depend on how you organize you pages it can be very simple to preset the filter
property of the postData
. You can for example include on the corresponding server generated page the inline <script>
which define a global variable with the filter
and use it in the grid definition. The filter you can set user depended.
I suggested Tony (see here) to include more support for predefined filters. In my vision if would be nice to predefine some probably complex filters and allow the user choose the filter by name. The way seems me especially good for the corporate clients.
来源:https://stackoverflow.com/questions/5271788/in-jqgrid-is-there-a-way-to-programatically-set-multi-search-filter-criteria-f