Sunday, December 9, 2012

ExtJS 4–Data Framework–Models-Association–Part 3

The models can be associated to create complex data model. Both single values and multi valued association can be defined in Ext Data framework. The association are defined using “associations” configuration in model.

Lets take for example we have Person and Address model. The association is that Person has multiple address (Shipping, billing etc.).

The code snippet below describes the two model as discrete class. we will had association in next snippet.


Ext.define('Training.model.Person', {
extend:'Ext.data.Model',
fields:[
{
name:'firstname',
type:'string'
},
{
name:'lastname',
type:'string'
},
{
name:'dob',
type:'date',
dateFormat:'m-d-Y'
},
{
name:'single',
type:'boolean'
},
{
name:'gender',
type:'string'
}
]

});

Ext.define('Training.model.Address', {
extend:'Ext.data.Model',
fields:[{
name:'street',
type:'string'
},{
name:'city',
type:'string'
}]
});

  

No comments:

Post a Comment