Models

Models represent objects or entities inside our application, for example, Clients, Users, Invoices, and so on. Those models will be used by the data stores. We can define as many models as we need inside our application.

A model may contain fields, validations, and relationships between other models. We can also set a proxy to persist and pull our data.

Note

As of version 5.x, field definitions can be optional unless you need conversion, validations, or set an implicit data type. For more information, take a look at http://docs.sencha.com/extjs/5.1/whats_new/5.0/whats_new.html#Models.

To create a model, let's write the following code:

Ext.define('Myapp.model.Client',{
extend:'Ext.data.Model',  // step 1
idProperty:'clientId ', // step 2
fields:[ ...

Get Learning Ext JS - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.