In this recipe, we will see how to make use of the model that we created in the previous recipe to populate the fields in a form.
Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.
Carry out the following steps:
Create and open a new file named
ch05_02.js
and paste the following code into it:Ext.setup({ onReady: function() { Ext.regModel('User', { fields: [ {name: 'name', type: 'string'}, {name: 'age', type: 'int'}, {name: 'phone', type: 'string'}, {name: 'email', type: 'string'}, {name: 'alive', type: 'boolean', defaultValue: true} ], changeName: function() { var oldName = this.get('name'), newName = oldName + " Azad"; this.set('name', newName); } }); var user = Ext.ModelMgr.create({ name : 'Ajit Kumar', age : 24, phone: '555-555-5555', email: '[email protected]...