一、创建Model模型
Extjs4.10提供了两种方法来创建Model模型,也就是创建类
方法一:
Ext.define('person',{
extend:'Ext.data.Model' //必须继承类
fields:[
{name:'name',type:'auto'},
{name:'age',type:'int'},
{name:'email',type:'auto'},
]
});
方法二:
Ext.regModel('person',{
fields:[
{name:'name',type:'auto'},
{name:'age',type:'int'},
{name:'email',type:'auto'}
]
});
优点:不能每次都extend:'Ext.data.Model'
二、实例化Model模型:
Extjs4.10提供了三种方法来实例化Model模型
方法一:
var p = new person({
name:'zhangsan',
age:28,
email:'zhangsan@qq.com'
})
alert(p.get('name'));
方法二:
var p1 = new Ext.create('person',{
name:'zhangsan',
age:28,
email:'zhangsan@qq.com'
})
alert(p1.get('name'));
方法三:
var p3 = Ext.ModelManager.create({
name:'zhangsan',
age:28,
email:'zhangsan@qq.com'
},'person');
alert(p3.get('name'));