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

Filter Data Source with And and Or

1 Answer 61 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Salim
Top achievements
Rank 1
Salim asked on 19 Sep 2017, 01:56 PM

As per the documentation, we can filter the datasource with only one logic: either "or" or "and". I need to filter as per the following logic:

(condition 1) and ((condition 2) or (condition 3))

Is it possible?

If not, is there in the operator something like "in" so that I can do the following logic:

(condition 1) and ( x in ("value 1", "value 2"))?

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 21 Sep 2017, 08:29 AM
Hello Salim,

You can use the logic option of the filter expression syntax to determine the logic of a given expression.
(condition 1) and ((condition 2) or (condition 3)) would look like this:
var filterExpr = {
  logic: "and",
  filters: [
    {field: "FieldName", operator: "eq", value: val},
    {logic: "or", filters: [
      {field: "FieldName2", operator: "eq", value: val2},
      {field: "FieldName2", operator: "eq", value: val3}
    ]}
  ]
};

Here is a Dojo demonstrating the result:
http://dojo.telerik.com/@tsveti/ICigI

Regards,
Tsvetina
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Salim
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or