What is kendo.data.Model

2 posts, 0 answers
  1. Bilal
    Bilal avatar
    109 posts
    Member since:
    Oct 2014

    Posted 30 Oct 2014 Link to this post

    Hi,

    From what I understood from the documentation, the kendo.data.Model inherits from the ObservableObject. 

    1- Does this mean that I can create a new Model and make it my "viewmodel" in terms of MVVM? Or i should be creating explicitly a viewModel from the ObservableObject?

    2- In DataSource schema.model. Why would I define a model on the DataSource schema? Where is it being used? Is the schema.model used to track the records add/deleted/updated? Does it have any role when loading data from server? 

    Thanks
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 03 Nov 2014 Link to this post

    Hi Bilal,

    1. Yes you can. Please check the following example:
    <input data-bind="value: name" />
    <input data-bind="value: age" />
     
    <script>
      var Person = kendo.data.Model.define( {
        id: "personId", // the identifier of the model
        fields: {
          "name": {
            type: "string"
          },
          "age": {
            type: "number"
          }
        }
      });
      var person = new Person( {
        name: "John Doe",
        age: 42
      });
     
      kendo.bind($(document.body), person);
    </script>

    2. The model is used to describe record fields and define the model ID. The field configurations such as type, editable, defaultValue, validation are being used by other Kendo UI components such as DataSource, Grid and etc. For example the field type 'tells' the dataSource to parse the incoming JSON value as a number or JavaScript date object. It also 'tells' the Grid what type of an editor to render and what filter operators to show.

    Is the schema.model used to track the records add/deleted/updated?
    Yes, the ID field has main role in tracking added/deleted records.

    Does it have any role when loading data from server?
    Yes, it is used for describing the way incoming JSON data should be parsed on the client.

    Regards,
    Alexander Valchev
    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