How to do deeper filter in kendo DataSource

2 posts, 0 answers
  1. Ambica
    Ambica avatar
    6 posts
    Member since:
    Dec 2012

    Posted 06 Feb 2013 Link to this post

    Hi ,

    I have Employee Datasource  as below

    var obj = [
        {
            "Id": "1",
            "Name": "Ambica",
            "addresses": [
                {
                    "City": "Bangalore",
                    "State": "Karnataka"
                },
                {
                    "City": "Mysore",
                    "State": "Karnataka"
                }
            ]
        },
        {
            "Id": "2",
            "Name": "Manu",
            "addresses": [
       {
           "City": "Bangalore",
           "State": "Karnataka"
       },
                {
                    "City": "Mysore",
                    "State": "Karnataka"
                }
            ]
        }
    ];

    var EmployeeDS = new kendo.data.DataSource({
        data: obj
    });

    here my requirement is get employee record whose name is "Ambica" and city is "bangalore".

    so how can i filter my EmployeeDS??

    Have written filter as below but its not filtering (Only one level is filtering)

    EmployeeDS.filter([{
        "logic": "and",
        filters: [{ field: "Name", operator: "contains", value: "Ambica" },
                  { field: "addresses.City", operator: "equal", value: "Bangalore" }
        ]
    }]);
  2. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 08 Feb 2013 Link to this post

    Hi Ambica,

    Although, such array filter is not supported out-of-the-box, you can use a custom filter expression to achieve this. Here is a test page which illustrates a basic implementation.

    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top