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

Modelling multiple child items

1 Answer 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nigel
Top achievements
Rank 1
Nigel asked on 23 Dec 2015, 10:01 AM

Hi,

I have a Kendo grid reading from a DataSource that maps to some JSON returned from our application's API. The JSON contains some main objects which can have zero or more subobjects, like this:

[
  {
    "itemId": 123,
    "text": "blah",
    "subItems": [
      {
        "subItemId": 1,
        "subItemText": "foo"
      },
      {
        "subItemId": "2",
        "subItemText": "banana"
      }
    ]
  }, ...
]

 Using DataSource.schema.model I can easily define the data types for the fields in the main objects:

var dataSource = new kendo.data.DataSource({
  schema: {
    model: {
      id: 'itemId',
      fields: {
        itemId: { type: 'number' },
        text: { type: 'string' }
      }
   });

How do I go about defining the model for the fields in the subitems?

Thanks for any help,

 

Nigel

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Dec 2015, 07:18 AM
Hello Nigel,

You can check the HierarchicalDataSource provided by Kendo UI:
http://docs.telerik.com/kendo-ui/framework/hierarchicaldatasource/overview

Here is the article describing the available methods and configuration:
http://docs.telerik.com/kendo-ui/api/javascript/data/hierarchicaldatasource

Hope this helps.

Regards,
Eyup
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
Nigel
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or