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

Setting schema for json datasource

1 Answer 1444 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Kelly
Top achievements
Rank 1
Kelly asked on 21 Sep 2011, 01:27 AM
I have a json datasource that looks like:

{
    "people": [{
        "name": "John Smith",
        "phone": "(519) 420-2391",
        "address": {
            "street": "123 Main St",
            "city": "Someplace"
        }
    }]
}

And I would like to map the address fields in a kendo Grid.
I tried setting the schema based on the "Binding to XML" example:
new kendo.data.DataSource({
        data: people,
        schema: {
            type: 'json',
            data: 'people',
            model: {
                fields: {
                    name: 'name',
                    phone: 'phone',
                    address_street: 'address/street',
                    address_city: 'address/city'
                }
            }
        }
    })

But I'm getting some js error (q is undefined).

What's the correct way of doing this?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 26 Sep 2011, 11:32 AM
Hello Kelly,

 
Currently, grid does not bind to models. So, in this case defined model is not interpreted by the grid. Check this jsFiddle demo, which I have created in order to implement required functionality. 

Best regards,
Georgi Krustev
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
Kelly
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or