Book Image

Ext JS Application Development Blueprints

Book Image

Ext JS Application Development Blueprints

Overview of this book

Table of Contents (18 chapters)
Ext JS Application Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Data first


All our models will inherit from a base model, which will be used to specify the following command:

// app/model/BaseModel.js
Ext.define('Instrumatics.model.BaseModel', {
    extend: 'Ext.data.Model',

    schema: {
        namespace: 'Instrumatics.model',
        urlPrefix: 'http://localhost:3000',
        proxy: {
            type: 'ajax',
            url: '{prefix}/{entityName:uncapitalize}'
        }
    },
});

Note

We've assumed that we have an API server running at localhost on port 3000 and supplied this information as the URL prefix.

We used the schema configuration in the last chapter, but now that we're about to use it with multiple models, it really comes into its own. In each of the models that inherit from BaseModel, the model's name will be inserting into the proxy URL in place of the entityName token. This avoids duplicating the URL configuration across multiple models. We can now create our LogEntry model as per our design:

// app/model/LogEntry.js
Ext.define('Instrumatics...