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

How to do deeper filter in kendo DataSource

1 Answer 52 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Ambica
Top achievements
Rank 1
Ambica asked on 06 Feb 2013, 10:33 AM
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" }
    ]
}]);

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 08 Feb 2013, 07:50 AM
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!
Tags
Data Source
Asked by
Ambica
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or