Book Image

Learning Ext JS_Fourth Edition

Book Image

Learning Ext JS_Fourth Edition

Overview of this book

Table of Contents (22 chapters)
Learning Ext JS Fourth Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a module


Before we create the customer module, we are going to reuse the code written in Chapter 7, Give Me the Grid. To be more precise, we are going to use the code made in example 07 and make slight changes. First, for the model, we'll use the following code:

Ext.define(' myApp.model.Customer',{
  extend: 'Ext.data.Model',
  requires:  ['myApp.model.Contract'],
  idProperty: 'id',
  fields: [
  {name: 'id', type: 'int'},
  {name: 'name', type: 'string'},
  {name: 'phone', type: 'string'},
  {name: 'website', type: 'string'},
  {name: 'status', type: 'string'},
  {name: 'clientSince', type: 'date', dateFormat: 'Y-m-d H:i'},
  {name: 'country', type: 'string'},
  {name: 'sendnews', type: 'boolean'},
  {name: 'employees', type: 'int'},
  {name: 'contractInfo', reference: 'Contract', unique:true}
  ]
});

For the Customers file, add the following code:

Ext.define('myApp.store.Customers', {
  extend: 'Ext.data.Store',
  requires: [
    'myApp.model.Customer',
    'Ext.data.proxy.Ajax...