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

Grid / Filter row Issue: For Nested JSON, controls are not binding.

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
P r e m k u m a r
Top achievements
Rank 1
P r e m k u m a r asked on 04 May 2015, 10:13 AM

I'm trying to bind the nested object data to the grid control. Data binding is working fine. But I'm facing problem in filtering row.
In the filter, the controls are not loading/binding based on the field type. 

E.g.
From the below code snippet. I'm binding data and applying filter row for the same. But I'm not getting the data-picker as we have it in the demo. Attached the screenshot for your reference.

JSON:
var reportSummary = [{
        "schedule": {
            "id": 47,
            "name": " Schedule12",
            "description": "Blasting",
            "startDate": "2015-03-14",
            "endDate": "2015-03-17"
        },
        "frequency": {
            "id": 19,
            "scheduleId": 47,
            "frequency": "Daily",
            "interval": 1
        },
        {
        "schedule": {
            "id": 45,
            "name": " Schedule15",
            "description": "Test",
            "startDate": "2015-03-15",
            "endDate": "2015-03-20"
        },
        "frequency": {
            "id": 19,
            "scheduleId": 45,
            "frequency": "Monthly",
            "interval": 1
        }
    }]
  
  
Script:
$(document).ready(function () {
            $("#grid").kendoGrid({
                dataSource: {
                    data: reportSummary,
                    schema: {
                        model: {
                            fields: {
                                schedule: {
                                    name: {type: "string"},
                                    description: {type: "string"},
                                    startDate: {type: "date"}
                                }
                            }
                        }
                    },
                    pageSize: 20
                },
                height: 550,
                scrollable: true,
                sortable: true,
                filterable: {
                    mode: "row"
                },
                pageable: {
                    input: true,
                    numeric: false
                },
                columns: [
                    {field: "schedule.name", title: "Name", format: "{0:c}", width: "130px"},
                    {field: "schedule.description", title: "Description", width: "130px"},
                    {field: "schedule.startDate", title: "Start Date", width: "130px"}
                ]
            });
        });

Appreciate your support on this issue.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 06 May 2015, 08:04 AM
Hello,

Currently  nested model fields are not supported. You have to flatten your model. Something like this:

           dataSource: {
                    data: reportSummary.map(function(item) { return item.schedule }),
                    schema: {
                        model: {
                            fields: {
                                    name: {type: "string"},
                                    description: {type: "string"},
                                    startDate: {type: "date"}
                            }
                        }
                    }
            },
            columns: [
                    {field: "name", title: "Name", format: "{0:c}", width: "130px"},
                    {field: "description", title: "Description", width: "130px"},
                    {field: "startDate", title: "Start Date", width: "130px"}
            ]
Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
P r e m k u m a r
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or