I have been using filters to successfully search on my KendoUI grids. However a new application has some fields that are multi-valued and my filtering doesn't work - it actually just seems to spin forever.
An example of a multi-value field:
field : "rspPersons",
title : "Responsible Persons",
type : "Text",
template: "# var t=rspPersons.join(', ');data.tagsString=t; # #=t #"
An example of my filter:
orfilter.filters.push( {
field : "chgDescription",
operator : "contains",
value : v1
},
orfilter.filters.push( {
field : "rspPersons",
operator : "contains",
value : v1
}
The second filter will make the entire search break down. If I take it out, then the search/filter works just fine.
So how can I filter/search on multi-value fields?
You'll need to push multiple filter criteria into filter array and assign it to the of Grid's datasource. Here's how I have done.
function onChange() {
var filter = { logic: "or", filters: [] };
// values is an array containing values to be searched
var values = this.value();
$.each(values, function (i, v) {
filter.filters.push({ field: "column_name", operator: "eq", value: v
});
});
var dataSource = $("#searchgrid").data("kendoGrid").dataSource;
dataSource.filter(filter);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With