How do i search all columns of kendo grid at the same time? -
i have tried person has done, , works flawlessly, thank post:
search columns in kendoui grid
however, problems having when try search more 1 column @ time, space new word no longer works well.
how tell ignore spaces , keep searching contains?
so if search "verizon lte" when search itself, "verizon" or "lte" works search should, when they're together, returns 0 results, instead of including both items.
this current search, , same style link above
$(document).ready(function () { //change event $("#search").keyup(function () { var val = $('#search').val(); $("#grid").data("kendogrid").datasource.filter({ logic: "or", filters: [ { field: "serviceprovidername", operator: "contains", value: val }, { field: "manufacturername", operator: "contains", value: val }, { field: "modelnumber", operator: "contains", value: val }, { field: "modelname", operator: "contains", value: val }, { field: "technology", operator: "contains", value: val }, { field: "ostypename", operator: "contains", value: val } ] }); }); });
is limitation of kendo grid filtering?
when filter, default kendoui trying match entire phrase type. if put in "verizon" match contains "verizon". if put in "lte" match contains "lte". however, when put in "verizon lte" match containing "verizon lte", whereas seems want match "verizon", "lte", , "verizon lte" (which happen anyway when matches on first two.
in order type of filtering happen, need pre-process val
in filtering function in order create array of search terms, using space token splitter, , perform filter on each member of array , return aggregate result.
so, in order split search term spaces:
var val = $("#search").val().split(" ");
this make val array rather literal value, you'll need generate filter array based on each value in array. there number of ways it, here's 1 approach:
filters: getfieldfilter("serviceprovidername", "contains", val) .concat(getfieldfilter("manufacturername", "contains", val)) .concat(...);
...where getfieldfilter might this:
function getfieldfilter(field, operator, values) { var ret = []; for(var = 0; < values.length; i++) { ret.push( { field: field, operator: operator, value: values[i] }); } return ret; }
Comments
Post a Comment