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

Kendo Ui Model Schema definition

1 Answer 193 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Stephan
Top achievements
Rank 1
Stephan asked on 04 Mar 2016, 02:39 PM

Hi, 

I've currentrly working with kendo-UI and more specificly with its models. And I've a problem with the schema definition. Indeed when I read the documentation, I can see that the field "from" exist in the schema definition. It's a means to make a relatiship between my model and the data JSON received.

Example

01.var Product = kendo.data.Model.define( {
02.        id: "id",
03.        fields: {
04.            id: { type: "number", editable: false },
05.            importedField: {
06.                type: "string",
07.                from: "bar"
08.            }
09.        }
10.    });
11. 
12.    var a = new Product({bar : "Hello World", id : 1});

So, in theory if I make a new instance of Product, I should found a field "importedField" on my current object. But the field doesn't exist and "bar" is defined.
Second remaks : If i use a Kendo.data.DataSource and define my product model in this parameters, the field "bar" is replaced by "importedField" (without touch my model class)

Somebody has an idea ?
thank's lot
Stephan

Note : I'm realy sorry for my english :)

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 08 Mar 2016, 10:56 AM
Hello Stephan,

The "from" projection option is used only when the DataSource component parses the received JSON. In other words, this is used only when the coming JSON is parsed in the schema.parse callback. In all other cases, the schema.model configuration will not be used.

When a new Model is created on the client using JavaScript, the developer is responsible for passing the correct data structure, as it knows the proper field values of the model schema.

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
MVVM
Asked by
Stephan
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or