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

[Solved] how to define new datasource as a field in the the Schema definition

1 Answer 80 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
fbaptiste
Top achievements
Rank 1
fbaptiste asked on 12 Nov 2014, 08:04 PM
The kendo documentation has the following example for defining a datasource schema:

var dataSource = new kendo.data.DataSource({
  schema: {
    model: {
      id: "ProductID",
      fields: {
        ProductID: {
          //this field will not be editable (default value is true)
          editable: false,
          // a defaultValue will not be assigned (default value is false)
          nullable: true
        },
        ProductName: {
          //set validation rules
          validation: { required: true }
        },
        UnitPrice: {
          //data type of the field {Number|String|Boolean|Date} default is String
          type: "number",
          // used when new model is created
          defaultValue: 42,
          validation: { required: true, min: 1 }
        }
      }
    }
  }
});

this schema definition works for basic fields such as string, number etc but what if i wanted to have another field which is an inner datasource? for example:

var dataSource = new kendo.data.DataSource({
  schema: {
    model: {
      id: "ProductID",
      fields: {
        AttributesDataSource: new kendo.data.DataSource({
              // datasource config here
           })
      }
    }
  }
});


tried this. no error is given, but the inner datasource is always empty. is that the correct way to achieve this? is there an online example for such scenerio?

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 14 Nov 2014, 11:14 AM
Hi Fred,

Well this behavior is expected, as the Kendo UI DataSource does not support another DataSource being nested inside. And there is no workaround that I can provide you with in order to achieve this.

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