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

data source with multiple filters

3 Answers 140 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Cecil
Top achievements
Rank 1
Cecil asked on 14 Oct 2015, 03:54 PM

I am having problems with and or/and filter.  The attached jpg shows the filter as I now have it.

When i run this, it looks as though the field "EmployeeId" in Filter 1 does not work.  I get almost 9000 records when there should only be 147.

If I run each filter separately, Filter 1 gives my 145 records and then Filter 2 gives me 2 records, which are exactly the records I am looking.

 

So I know Filter 1 and Filter 2 are correct, but when I use the Logic "or" as in the jpg, it does not work.

How have I coded this wrong.

Thanks in advance.

 

3 Answers, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 14 Oct 2015, 07:09 PM
Hi Cecil,

Take a look at this demo illustrating with 3 AND statements inside an OR statement.  It shows the correct approach how to filter using filter.logic.  

Here's what I am using in my demo:
filter: {
  logic: "or",
  filters: [
    {
      logic: "and",
      filters: [
        { field: "ShipCity", operator: "eq", value: "Reims" },
        { field: "OrderDate", operator: "gt", value: janDate},
        { field: "Freight", operator: "lt", value: 100 }
      ]
    },
    {
      logic: "and",
      filters: [
        { field: "ShipCity", operator: "eq", value: "Lyon" },
        { field: "OrderDate", operator: "gt", value: janDate},
        { field: "Freight", operator: "lt", value: 100 }
      ]
    },
    {
      logic: "and",
      filters: [
        { field: "ShipCity", operator: "eq", value: "Rio de Janeiro" },
        { field: "OrderDate", operator: "gt", value: janDate},
        { field: "Freight", operator: "lt", value: 100 },
        { field: "ShipName", operator: "neq", value: "Ricardo Adocicados" },
      ]
    },
 
  ]
},

Make sure your values correspond to the field's type.  For example, janDate is a Date object and OrderDate is type: "date".  

Hopefully, this example will help clear things. 

Regards,
Pat
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Cecil
Top achievements
Rank 1
answered on 15 Oct 2015, 12:03 AM

Thanks Pat, but there doesn't seem to be any differences in the code, except you have an extra comma.

Here is what is wierd.  The only part of the filters that work are the first line of the filter.

Ex.  when CompanyId is first, it selects All the records from the company.  If I change it and make employeeId the first item in both filters, it selects All the records for that employee.  

Do I need to get with support on this?

0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 15 Oct 2015, 10:08 PM
Hi Cecil,

Unfortunately, I tried to get the same results you are getting with your filter, but was unable to.  Could you please either update my project or create a new dojo that replicates the issue?  Once I am able to see where the application is failing, I will be able to investigate further.

Regards,
Pat
Telerik
 
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
Cecil
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Cecil
Top achievements
Rank 1
Share this question
or