Stokes
14 Feb 2012, 9:06 AM
If I have a Model extension with certain fields, how can I extend that model and add a few specialized fields?
This seems like a pretty standard OO thing to do, but I can't find any examples that explain it. Something like this:
Ext.define('Fruit', {
extend: 'Ext.data.Model',
fields: [
{name:'ripe', type:'boolean'},
{name:'color', type:'string'}
]
});
Ext.define('Apple', {
extend: 'Fruit',
fields: [ // <-- this overwrites the parent's fields, which is not desired.
{name:'appleBreed', type:'string'}
]
});
// we'd like to be able to create a concrete class with fields from the child and parent.
var appleInstance = Ext.create('Apple', {
color: 'red',
appleBreed: 'Johnathan',
ripe: true
});
Any ideas?
Stokes.
This seems like a pretty standard OO thing to do, but I can't find any examples that explain it. Something like this:
Ext.define('Fruit', {
extend: 'Ext.data.Model',
fields: [
{name:'ripe', type:'boolean'},
{name:'color', type:'string'}
]
});
Ext.define('Apple', {
extend: 'Fruit',
fields: [ // <-- this overwrites the parent's fields, which is not desired.
{name:'appleBreed', type:'string'}
]
});
// we'd like to be able to create a concrete class with fields from the child and parent.
var appleInstance = Ext.create('Apple', {
color: 'red',
appleBreed: 'Johnathan',
ripe: true
});
Any ideas?
Stokes.