multiple filter conditions

1 Answer 4159 Views
Data Source
Jan
Top achievements
Rank 1
Jan asked on 29 Aug 2012, 10:14 PM
I can do something like
// returns data where orderId is equal to 10248 or customerName starts with Paul
filter: {
    logic: "or",
    filters: [
      { field: "orderId", operator: "eq", value: 10248 },
      { field: "customerName", operator: "startswith", value: "Paul" }
    ]
}

However, I am wondering... if it is possible to get filtering on condition like:
orderID is equal to 10248 or
( customerName starts with "Paul" and customerLastName start with "B" ) ?

Would you help me translate the conditions to filter: { ... } syntax?

Thank you,




1 Answer, 1 is accepted

Sort by
1
Accepted
Rosen
Telerik team
answered on 30 Aug 2012, 07:30 AM
Hello Jan,

You can have multiple nested filter descriptors, for example: 

dataSource.filter({
    logic: "or",
    filters: [
      { field: "fieldA", operator: "eq", value: 100 },
      {
         logic: "and",
         filters: [
             { field: "fieldA", operator: "lt", value: 100 },
             { field: "fieldB", operator: "eq", value: true }
         ]
     }
    ]
});

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Diga
Top achievements
Rank 1
commented on 15 May 2015, 10:38 AM

For nested filter, does the implicit logic "and" apply? Or we need to specify it explicitly?
Rosen
Telerik team
commented on 15 May 2015, 02:33 PM

Hello Diga,

The logic operator is determined by the parent composite descriptor. It should be set explicitly.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
William
Top achievements
Rank 1
commented on 16 Nov 2017, 04:19 PM

How do I add a logic operator "OR" for multi-select filters?

 

 

KendoFilters ofilters = new KendoFilters();
            ofilters.filters = new List<KendoFilter>();
            ofilters.logic("Or");
            if (candidate.CompanyName.HasValue())
            {
                ofilters.filters.Add(new KendoFilter() { field = "CompanyName", value = candidate.CompanyName, Operator = "contains" });
               
            }
            if (candidate.CompanyEmail.HasValue())
            {
                ofilters.filters.Add(new KendoFilter() { field = "CompanyEmail", value = candidate.CompanyEmail, Operator = "contains" });
            }

Plamen
Telerik team
commented on 21 Nov 2017, 11:50 AM

Hi,

You can refer to our documentation site here where the logic property is described - please have in mind that it should be written in  lower letters. 

Regards,
Plamen
Progress Telerik
Try our brand new, jQuery-free Angular 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
Jan
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or