This is a migrated thread and some comments may be shown as answers.

How to filter a datasource

1 Answer 87 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jaap
Top achievements
Rank 2
Jaap asked on 07 Feb 2012, 05:03 PM
Hi,

Let us say I have a dataSource with 2 columns: Name and Contact.
Now I have a searchValue on which I want to filter the dataSource with this expression: "Name == searchValue || Contact == searchValue".
How should I do that? Can't find documentation on that, only about simpel single field filters.
I use this to filter on one field:
dataSource.query({ filter: { field: "Name", operator: "contains", value: searchValue} }); 

But how should I do that with an "or" filter on a second field?
And is possible to use an expression?

Regards, Jaap

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 07 Feb 2012, 05:56 PM
Hello Jaap,

In order to construct an OR filter expression you should use similar to the following syntax:

{
    logic: "or",
    filters: [
       { field: "Name", operator: "contains", value: searchValue },
       { field: "Contact", operator: "contains", value: searchValue }
    ]
}

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Jaap
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Share this question
or