data source with multiple filters

4 posts, 0 answers
  1. Cecil
    Cecil avatar
    15 posts
    Member since:
    Dec 2011

    Posted 14 Oct 2015 Link to this post

    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.

     

  2. Patrick
    Admin
    Patrick avatar
    173 posts

    Posted 14 Oct 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Cecil
    Cecil avatar
    15 posts
    Member since:
    Dec 2011

    Posted 14 Oct 2015 in reply to Patrick Link to this post

    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?

  5. Patrick
    Admin
    Patrick avatar
    173 posts

    Posted 15 Oct 2015 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready