Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI Grid Filtering column with multiple values

Tags:

kendo-grid

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?

like image 413
Bryan Schmiedeler Avatar asked Oct 29 '25 17:10

Bryan Schmiedeler


1 Answers

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);
}
like image 51
Sangram Nandkhile Avatar answered Oct 31 '25 12:10

Sangram Nandkhile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!