Search code examples
searchjqgrid

jqgrid - how can I change search parameters?


I use standard search from navGrid toolbar (magnifier picture). I have found some ways to manipulate search, but nothing works... I just need to short options list to equal, less and more...


Solution

  • You receive the Search button in the navigation toolbar with respect of navGrid jqGrid method. The method create for you some standard buttons. You can specify which buttons you want include with respect of the next navGrid parameters. For example,

    jQuery("#grid_id").jqGrid('navGrid','#gridpager',
                              {add:false,edit:false,del:false});
    

    will add only "Refresh" (Reload) and "Search" buttons in the navigation toolbar. If the user click on one from the buttons the corresponding jqGrid method will be called. In case of "Add" and "Edit" operation if will be editGridRow method. In case of "Delete" button it will be delGridRow method, in case of "Search" button it will be searchGrid method and in case of "View" button it will be viewGridRow method. All from the methods has different parameters and events. To define the optons/parameters of the methods you can use additional parameters of the navGrid. For example, to use "Advanced Searching" dialog with custom searching options you can use the following form of the 'navGrid' call:

    jQuery("#grid_id").jqGrid('navGrid','#gridpager',
                              {add:false,edit:false,del:false}, // navGrid options
                              {},
                              {},
                              {},
                              {multipleSearch:true, sopt:['eq','ne','bw','cn']});
    

    In the most cased one don't change the common search rules per sopt. Instead of that one uses sopt property of the searchoptions property in the colModel. In the way you can define different set of search rules for different columns.