Kendo Ui Model Schema definition

2 posts, 0 answers
  1. Stephan
    Stephan avatar
    18 posts
    Member since:
    Jun 2008

    Posted 04 Mar Link to this post

    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 :)

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 08 Mar Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top