PDA

View Full Version : Extending Ext.data.Model



mdombos
28 Nov 2012, 10:00 AM
Hi All!

I tried to extend Ext.data.Model to create my own abstract model, but if the model is created via a store, the model hasn't got the functions and properties wich is declared in the new abstract model.



Ext.define('Ext.ux.data.NewModel',{
extend:'Ext.data.Model',
newFunction:function(){
alert('a');
},
newProperty:'value'
});

Ext.define('myModel',{
extend:'Ext.ux.data.NewModel',
fields:['one','two']
});

Ext.define('myStore',{
extend:'Ext.data.Store',
model:'myModel'
});
var a=new myStore;
console.log(a.getProxy().getModel().newProperty);
a.getProxy().getModel().newFunction();


Error message: TypeError: a.getProxy().getModel().newFunction is not a function

ettavolt
29 Nov 2012, 12:55 AM
Model is a class, and property/function you have added reside in instances of it. You may try to access them like this: store.getModel().prototype.newFunction()