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

DataSourceSchema structure

1 Answer 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ramy
Top achievements
Rank 1
Ramy asked on 02 Nov 2015, 10:00 AM

Hey,

I'm using php wrappers in order to build my Kendo remote binding Grid.
the restfull server is rendering the output as a JSON format using jsonapi.org v1.0 standard.

ex: {
  "links": {  ...  },
  "data": [
    {
      "type": "people",
      "id": "7",
      "attributes": {​...},
      "relationships": {...},
      "links": {...}
    }
  ],
  "included": [{...}]
}

using this standard will force you to separate the "foreign keys( ex: positions of the people , compound objects)" and include it into the "included" attribute
you can read more about it in the following link: http://jsonapi.org/format/#document-compound-documents

in my code:

working code:

$EmailAddressField = new \Kendo\Data\DataSourceSchemaModelField('EmailAddress');
$EmailAddressField->type('string');
$EmailAddressField->from('attributes.EmailAddress');
$schema = new \Kendo\Data\DataSourceSchema();
$schema ->model($model)->data('data');​

not working code:

$PositionField = new \Kendo\Data\DataSourceSchemaModelField('Position');
$PositionField->type('string');
$PositionField->from('included.attributes.​Description');
$schema = new \Kendo\Data\DataSourceSchema();
$schema ->model($model)->data(new \Kendo\JavaScriptFunction('function(result) { return result; }'));​

 i cant figure out how ​to link my schema->model->data to the whole object , not just the 'data', i need also to get the data that are inside the "included" attribute.

any help?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 04 Nov 2015, 09:35 AM
Hello Ramy,

You will need to combine the data and included fields into one list of data items. Thus the DataSource schema will be able to map the fields correctly and allow their editing. You can combine the data either in the schema.data callback or in a custom transport.read function.

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