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

What is kendo.data.Model

1 Answer 500 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Bilal
Top achievements
Rank 2
Bilal asked on 30 Oct 2014, 05:00 PM
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

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 03 Nov 2014, 10:07 AM
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!
 
Tags
Data Source
Asked by
Bilal
Top achievements
Rank 2
Answers by
Alexander Valchev
Telerik team
Share this question
or