Kendo Ui Model Schema definition

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

    Posted 04 Mar 2016 Link to this post


    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.


    01.var Product = {
    02.        id: "id",
    03.        fields: {
    04.            id: { type: "number", editable: false },
    05.            importedField: {
    06.                type: "string",
    07.                from: "bar"
    08.            }
    09.        }
    10.    });
    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 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

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

  2. Georgi Krustev
    Georgi Krustev avatar
    3747 posts

    Posted 08 Mar 2016 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.

    Georgi Krustev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top