====== Single field searching ======
Single field searching is a way to search data (at server) on one field at a time. When using this method we construct a modal form where the user can select a field and condition to apply the search.
{{ :wiki:simplesearch2.png | Singe Field serching}}
This method uses the url to post the search data and differ from the custom and toolbar search methods. The difference is that the posted search data is not in pair name:value. See below how data is posted.
===== 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 =====
or using the new API
Where
* grid_id is the id of the already constructed grid
* options is an array of settings in name: value pairs format.
Typically when this method is called it launches the modal dialog and makes the grid inaccessible until the dialog is not closed.\\
This method is the default search method in the [[navigator]] if the search is enabled. The search parameters in navigator can be set the same way as the options described below.
By default the dialog appears at upper left corner of the grid.
We add a new option overlay (default 10) in search dialog. If set to 0 the cover overlay is disabled and the user can interact with the grid.
===== Options =====
This method uses the following properties from language file grid.locale-xx and the can be passed in the options array of the serch method
$.jgrid = {
...
search : {
caption: "Search...",
Find: "Find",
Reset: "Reset",
odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain']
},
...
^Option^Type^Description^Default^
|afterShowSearch|function|This event fires (if defined) every time after the search dialog is shown|null|
|beforeShowSearch|function|This event fires (if defined) every time before the search dialog is shown|null|
|closeAfterSearch|boolean| If set to true this closes the search dialog after the user apply a search - i.e. click on Find button|false|
|closeAfterReset|boolean| If set to true this closes the search dialog after the user apply a reset - i.e. click on Reset button|false|
|drag|boolean|Enables or disables draging of the modal|true|
|jqModal|boolean|If set to true uses jqModal plugin (if present) to creat the dialogs. If set to true and the plugin is not present jqGrid uses its internal function to create dialog|true|
|resize|boolean|Enables or disables resizing of the modal|true|
|modal|boolean|Is set to true the search dialog becomes modal|false|
|width| integer|Defines the width os the search dialog| 450|
|height| mixed| Defines the height of the search dialog| auto|
|top| integer|the initial top position of modal dialog. The default value of 0 mean the top position from the upper left corner of the grid. When jqModal option is true (see below) and jqModal plugin is present any value different from 0 mean the top position from upper left corner of the window.|0|
|left| integer|the initial left position of modal dialog. The default value of 0 mean the left position from the upper left corner of the grid. When jqModal option is true (see below) and jqModal plugin is present any value different from 0 mean the left position from upper left corner of the window.|0|
|caption|string|The caption of the modal|see lang file|
|showQuery| boolean| If set to true shows the query which is generated when the user defines the conditions for the search. Valid only in advanced search. Again with this a button near search button appear which allows the user to show or hide the query string interactively | false|
|searchOnEnter| boolean|Determines whether search should be applied on pressing Enter key.| false|
|Find|string|The text in the find button|see lang file|
|multipleSearch|boolean|If set to true this activates the advanced searching|false|
|multipleGroup|boolean|If set to true this activates the advanced searching with a possibilities to define a complex conditions |false|
|odata|array|Translation strings that corresponds to the sopt options|see lang file|
|onClose|function|If defined this event fires when the dialog is closed. Can return true or false. If the event return false the dialog will not be closed|null|
|afterRedraw| function| This function if defined is lunched every time the filter is redrawed - the filter is redrawed every time when we add or delet rules or fields Tio this function we pass the search parameters as parameter | null|
|onSearch|function|If defined this event fires when the search Button is clicked.|null|
|onReset|function| If defined this function fire if reset button is activated |null|
|closeOnEscape| boolean | If this option is set to true the search dialog will be closed if the user press ESC key|false|
|onInitializeSearch|function|This event occurs only once when the modal is created|null|
|recreateForm| boolean | when set to true the form is recreated every time the search dialog is activated with the new options from colModel (if they are changed)|false|
|showOnLoad|boolean| This option is valid only in navigator options. If set to true the dialog appear automatically when the grid is constructed for first time| false|
|errorcheck| boolean | if searchrules are defined this turn on of error checking. If there is a error in the input the filter is not posted to the server and a error message appear.|true|
|Reset|string|The text for the clear (reset) button|see lang file|
|sField|string|See //sopt// description|searchField|
|sFilter|string|Aplicable to advanced searching. See advanced [[:wiki:advanced_searching | searching]] |filters|
|sOper|string|See //sopt// description|searchOper|
|sopt|array|Use this option to set common search rules. If not set all the available options will be used. All available option are: ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc','nu','nn'] The corresponding texts are in language file and mean the following: ['equal','not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain','is null','is not null'] Note that the elements in sopt array can be mixed in any order.| |
|sValue|string|See //sopt// description|searchString|
|overlay|integer|If this option is set to 0 the overlay in grid is disabled and the user can interact with the grid while search dialog is active | 10 |
|layer| string| If defined this should be a valid id in the DOM. Also if this option is set the filter is inserted as child of this element| null|
|tmplNames| array| Defines the name of the templates used for easy user input - by example like this : ['Template1', 'Template2',...]. See grid demo how to define templates.| null|
|tmplFilters|array of objects | if defined this should correspond to the tmplNames. See demo how to define template| null|
|tmplLabel| string| If a template is defined a select element appear between the Reset and Find buttons. This is a the text describing the select |Template:|
|zIndex|integer|The starting z-index for the dialog. If you will see the dialog form under another elements or dialogs you should use the parameter with some value higher as default value 950. In the most cases it should be the value higher as 1000 - the default value of jQuery UI dialog.|950|
As mentioned above posting search data differs from custom and toolbar searching. When the find button is clicked, jqGrid adds three parameters to the url (again with _search=true), in name=value pairs:
* sField: the 'searchField', the value comes from the index in colModel
* sValue: the 'searchString', the value is the entered value
* sOper: the 'searchOper', the value is the type of search - see sopt array
For example if the field index is invid, operation is equal, and the searched value is 123, then the string that is posted to the server look like:
http://localhost/demo35/server.php?...&searchField=invid&searchString=123&searchOper=eq
{{section>search_config#colmodel_options}}
{{section>search_config#colmodel_conventions}}