free-jqGrid filterToolbar Client-side search containing of some words -
how can configure free-jqgrid (4.8) filtertoolbar search word within field?
data
- one 2 3
- two 3 four
- one 4 three
search words
- "one four" , returns row 3
- "four three" , returns rows 2 , 3
- "one three" , returns rows 1 , 3
- "four" , returns rows 2 , 3
jqgrid api
$("#list").jqgrid({ datatype: "local", colnames: ["name"], colmodel: [{ name: "name", index: "name" }], caption: "viz test", pager: '#pager', search: true, multiselect: true, data: mydata }); jquery("#list").jqgrid('filtertoolbar', { searchoperators: true });
this based on answer , requires free-jqgrid 4.8 , see demo on jsfiddle
colmodel: [{ name: "name", index: "name", searchoptions: { sopt: ["sin", "bw", "cn", "lt", "le", "gt", "ge", "in", "ni"] } }], customsortoperations: { // properties of customsortoperations defines new operations // used in postdata.filters.rules items op peroperty sin: { operand: "sin", // displayed in searching toolbar text: "string in", // shown in searching dialog // or operation menu in searching toolbar filter: function (options) { // called filtering on custom operation "sin" // has following properties: // item - item of data (exacly in mydata array) // cmname - name of field need filtered // searchvalue - values in input field of searching toolbar var fielddata = options.item[options.cmname]; var words = options.searchvalue.split(" "); //loop thru each word in words array $.each(words, function () { //search word in fielddata var searchresults = fielddata.search(this) //if not fouond if (searchresults < 0) { fielddata = ""; } }); return fielddata; } }
Comments
Post a Comment