Is There A Way To Customize Search Rules In JqGrid In Particular Column?
Solution 1:
I had a similar problem and ended up solving it by editing some of the jqGrid source code.
I added additional operators to the ops array. (It was line 6130 in version 4.4.0.)
ops : [
{"name": "eq", "description": "equal", "operator":"="},
{"name": "ne", "description": "not equal", "operator":"<>"},
{"name": "lt", "description": "less", "operator":"<"},
{"name": "le", "description": "less or equal","operator":"<="},
{"name": "gt", "description": "greater", "operator":">"},
{"name": "ge", "description": "greater or equal", "operator":">="},
{"name": "bw", "description": "begins with", "operator":"LIKE"},
{"name": "bn", "description": "does not begin with", "operator":"NOT LIKE"},
{"name": "in", "description": "in", "operator":"IN"},
{"name": "ni", "description": "not in", "operator":"NOT IN"},
{"name": "ew", "description": "ends with", "operator":"LIKE"},
{"name": "en", "description": "does not end with", "operator":"NOT LIKE"},
{"name": "cn", "description": "contains", "operator":"LIKE"},
{"name": "nc", "description": "does not contain", "operator":"NOT LIKE"},
{"name": "nu", "description": "is null", "operator":"IS NULL"},
{"name": "nn", "description": "is not null", "operator":"IS NOT NULL"},
{"name": "to", "description": "to", "operator":"<"},
{"name": "fr", "description": "from", "operator":">"}
],
numopts :
['eq','ne','lt','le','gt','ge','nu','nn','in','ni'],
stropts :
['eq','ne','bw','bn','ew','en','cn','nc','nu','nn','in', 'ni','to','fr'],
Use these new options in the sopt parameter in your date column specification. (You may also need to adjust the back end to translate these operators depending on your search results implementation.)
{name:'mydatefield', searchoptions: {sopt:['to', 'fr']}}
Hope this helps.
Solution 2:
To use searching in jqGrid you call probably navGrid
function to add navigator with the search button. The function navGrid
has as the 6-th parameter an object (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator#definition) which can be used to overwrite any default parameters from $.jgrid.search
inclusive odata
parameter. So you can do something like following
jQuery("#list").jqGrid('navGrid','#pager',{search:true},{},{},{},
{odata:['equal','not equal', 'to', 'less or equal','from',
'greater or equal', 'begins with','does not begin with',
'is in','is not in','ends with','does not end with',
'contains','does not contain']});
Solution 3:
- jqGrid Version 4.5.4
- JQuery Version 1.9.0 (included in jqGrid Zip File)
- Chrome Version 31.0.1650.48 m
There is a Problem in Jquery 1.9/1.10 with Chrome 31.x : event.returnValue is deprecated. Please use the standard event.preventDefault() instead. http://bugs.jquery.com/ticket/14320
Replace the following code (JQuery 2.x version) => remove src.returnValue
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = (src.defaultPrevented ||
src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
can work for me
Post a Comment for "Is There A Way To Customize Search Rules In JqGrid In Particular Column?"