First, create model models
EXTJS4.10 provides two ways to create model models, that is, to create classes
Method One:
ext.define (' person ', {
Extend: ' Ext.data.Model ' //must inherit class
fields:[
{ Name: ' Name ', type: ' auto '},
{name: ' Age ', type: ' int '},
{name: ' email ', type: ' Auto '},
]
});
Method Two:
Ext.regmodel (' person ', {
fields:[
{name: ' name ', type: ' Auto '},
{name: ' Age ', type: ' int '},
{name: ' email ', type: ' Auto '}
]
});
Advantages: Can not be extend every time: ' Ext.data.Model '
Second, the model models of instantiation:
EXTJS4.10 provides three ways to instantiate model models
Method One:
var p = new Person ({
Name: ' Zhangsan ',
Age:28,
Email: ' [email protected] '
})
Alert (p.get (' name '));
Method Two:
var p1 = new Ext.create (' person ', {
Name: ' Zhangsan ',
Age:28,
Email: ' [email protected] '
})
Alert (p1.get (' name '));
Method Three:
var p3 = Ext.ModelManager.create ({
Name: ' Zhangsan ',
Age:28,
Email: ' [email protected] '
}, ' person ');
Alert (p3.get (' name '));