Filter Data Source with And and Or

2 posts, 1 answers
  1. Salim
    Salim avatar
    61 posts
    Member since:
    Jun 2016

    Posted 19 Sep Link to this post

    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"))?

     

  2. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    2087 posts

    Posted 21 Sep Link to this post

    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.
Back to Top