This is an old revision of the document!
Table of Contents
Advanced Searching
Advanced searching is a way to search on multiple fields and the same time with different conditions. Advanced searching and single searching use the same method, but with different setting and posting data.
Installation
In order to use this method the following modules should be included when downloading the grid: Common, Form Edit, Search Plugin. For more information refer to Download
Calling Conventions
<script> ... jQuery("#grid_id").searchGrid( {multipleSearch:true,...} ); ... </script>
or using the new API
<script> ... jQuery("#grid_id").jqGrid('searchGrid', {multipleSearch:true,...} ); ... </script>
Where
- grid_id is the id of the already constructed grid
- multipleSearch:true activates the advanced searching
- … other options set as name:value pair
Typically when this method is called it lunches the modal dialog and make so that the grid is not accessible until the dialog is not closed.
This method is not the default search method in the navigator. To enable this you should either set the defaults search options using the extend method or set it in the navigator in the place of the search options.
The advanced searching can look like this when created:
As you can see the user can add or delete a unlimited conditions to perform the search.
To add a condition the plus button should be pressed.
To delete a condition a minus button should be pressed.
Options
We have the same options as those from Singe Searching
Below we consider only these options that are connected with the advanced search.
As mentioned above the first options is
- multipleSearch:true - This option activates the advanced searching
The second option is:
- sFilter - this option determines the name of the posting data. The default value is filters.
When the search data is posted to the server we add only one parameter (again with _search=true) to the url and this is the filters element.
The posted data can look like this:
filters = {"groupOp":"AND", "rules":[ {"field":"invdate","op":"ge","data":"2007-10-06"}, {"field":"invdate","op":"le","data":"2007-10-20"}, {"field":"name","op":"bw","data":"Client 3"} ] }
As your notice the posted data is a JSON string with the following parameters:
- groupOp this determines the rules of the search. Can be AND or OR. This option can be changed from the user with a help of the select box near to Reset button. When the user select all (English variant) the AND is set. When the user select any the OR is set.
- rules is array with the following options
- field - the field property contain the name of the selected index (or name) from colModel
- op - determines the condition of the searching. see the sopt in the options
- data - is the entered data to be search
Discussion
Hi to all, I'm using version 3.8.2 jqgrid that is really powerful. But I found a problem using multiple search with IE7 or IE8 in IE7 compatibility. In short, if I apply the policy OR a multiple search it comes back to me “undefined” in parameter “op”from the second rule of research on, and if you click the “Reset”gives the following error: 'find (.. .) .0 'is null or not an object jquery.jqGrid.min.js, Line 323 Column 356 The bug is replicable playing with the jqgrid demo “New in version 3.7 > Multiple Search” Bye Gabriele
p.s. i found a workaround here http://www.trirand.com/blog/?page_id=393/bugs/in-multiple-search-second-and-subsequent-ops-are-sent-as-undefined-in-ie6/
Is there a way to prefill filters on page load?
why? why? why?
why the parameter “filters” can not be defined as {“groupOp”:“AND”,”rules”:[{“field”:“a.id”,”op”:“eq”,”data”:“2121”,”type”:“integer”}]}; type : date , string , integer , number or customType ….