Edit this page


Defines a new Model type using the provided options. The returned value inherits from the kendo.data.Model class.

Example - Define a model

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

console.log(person.get("name")); // outputs "John Doe"
console.log(person.get("age")); // outputs 42


options Object

Describes the configuration options of the new model type.

options.id String

The name of the field which acts as the identifier of the model. The identifier is used to determine if a model instance is new or existing one. If the value of the field specified is equal to the default value (specified through the fields configuration) the model is considered as new.

options.fields Object |Array

A set of key/value pairs the configure the model fields. The key specifies the name of the field. Quote the key if it contains spaces or other symbols which are not valid for a JavaScript identifier.

A field configuration cannot contain nested fields' configurations.


Specifies the default value which will be used for the field when a new model instance is created. The default settings depend on the type of the field. The default value for "string" is "", for "number" is 0, and for "date" is new Date() (today).

The parameter can also be set to a function that returns the dynamic default values of the fields. For a live demo, refer to this how-to example.

options.fields.fieldName.editable Boolean

Specifies if the field is editable or not. The default value is true.

options.fields.fieldName.nullable Boolean

Specifies if the defaultValue setting should be used. The default is false.

options.fields.fieldName.parse Function

Specifies the function which will parse the field value. If not set default parsers will be used.

options.fields.fieldName.type String

Specifies the type of the field. The available options are "string", "number", "boolean", "date" and "object". The default is "string".

options.fields.fieldName.from String

Specifies the field of the original record whose value is used to populate the Model field. When CRUD operations (specifically adding new items) are enabled, the original field name should be defined with a defaultValue as well, because during updates and creates the Kendo UI DataSource will try to construct a data item object, which matches the original (server-side) data item structure. For more information and an example, please refer to How to Use Nested Model Properties.

options.fields.fieldName.validation Object

Specifies the validation options which will be used by Kendo Validator.

Example - define the fields of a model

var Product = kendo.data.Model.define( {
    id: "id", // the identifier is the "id" field (declared below)
    fields: {
        /* name of the field */ name: {
            type: "string", // the field is a string
            validation: { // validation rules
                required: true // the field is required
            defaultValue: "<empty>" // default field value

        /* name of the field */ price: {
            type: "number", // the field is a number
            validation: { // validation rules
                required: true, // the field is required
                min: 1 // the minimum value is 1
            defaultValue: 99.99 // default field value

        /* name of the field */ id: {
            editable: false, // this field is not editable
            nullable: true // a default value will not be assigned
var product = new Product();
console.log(product.get("price")); // outputs "99.99" which is the default value
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article