This is an old revision of the document!


Advanced Searching

Advanced searching is a way to search on multiple fields at the same time with different conditions. Advanced searching and single searching use the same method, but with different settings and posting data.

Installation

In order to use this method the following modules should be included when downloading the grid: Common, Form Edit, filter 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

To set more advanced search do:

<script>
... 
jQuery("#grid_id").jqGrid('searchGrid', {multipleSearch:true,...} );
...
</script>
  • multipleGroup:true activates the more advanced search dialog allowing to add complex group conditions

Typically when this method is called it launches the modal dialog and makes it so the grid inaccessible until the dialog is closed.
This method is not the default search method in the navigator. To enable this you should either set the default 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:

Advenced Searching

As you can see the user can add or delete an unlimited number of conditions to perform the search.
To add a condition the plus button should be pressed.
To delete a condition the minus button should be pressed.

Options

We have the same options as those from Single Searching
Below we consider only these options that are connected with the advanced search.
As mentioned above the first option 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":"OR",
    "rules":[{"field":"a.id","op":"eq","data":"1"}],
    "groups":[
         {
             "groupOp":"AND",
             "rules":[{"field":"a.id","op":"eq","data":"2"}],
             "groups":[...]
         }
     ]
}

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 the help of the select box near the Reset button. When the user select all (English variant) the AND is set. When the user selects any the OR is set.
  • rules - an array with the following options
    • field - the field property contains 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 searched on
  • groups - set of other groupOp, rules elements to define a complex search query

Discussion

Gabriele, 2011/01/27 15:05, 2011/01/27 15:24

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/

Donato, 2011/04/18 07:48

Is there a way to prefill filters on page load?

laineyc, 2013/01/26 18:13, 2013/01/26 18:17

why? why? why?8-)


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 ….

You could leave a comment if you were logged in.

QR Code
QR Code wiki:advanced_searching (generated for current page)