Alexander Bauer
5 Sep 2012, 4:37 AM
Hi there,
I am trying to extend the Ext.data.Store class, since I have many stores which follow the same properties/proxies. Therefore I declared a class
Ext.define('AbstractStore', {
extend : 'Ext.data.Store',
model : null,
....
constructor : function (config) {
var me = this;
// this makes sense
me.proxy.url = arguments[0].url || me.url;
// why I have to call this ?
if (me.model) {
me.proxy.model = me.model;
}
me.callParent([config]);
}
});
This works fine, but when having 2+ classes which extend the AbstractStore, the second class has the same model of the first one. That said:
Ext.define('StoreA', {
extend : 'AbstractStore',
model : 'modelA'
});
Ext.define('StoreB', {
extend : 'AbstractStore',
model : 'modelB'
});
StoreB will load the data all fine, but the associated model will be 'modelA' if I remove the 'me.proxy.model' part. I noticed that the Store class is being extended using prototype and all of the properties are stored on prototype. This is maybe the reason why they share properties.
Do they share the proxy instance ?
If a remove the Abstract layer, with the same config everything works fine.
I am trying to extend the Ext.data.Store class, since I have many stores which follow the same properties/proxies. Therefore I declared a class
Ext.define('AbstractStore', {
extend : 'Ext.data.Store',
model : null,
....
constructor : function (config) {
var me = this;
// this makes sense
me.proxy.url = arguments[0].url || me.url;
// why I have to call this ?
if (me.model) {
me.proxy.model = me.model;
}
me.callParent([config]);
}
});
This works fine, but when having 2+ classes which extend the AbstractStore, the second class has the same model of the first one. That said:
Ext.define('StoreA', {
extend : 'AbstractStore',
model : 'modelA'
});
Ext.define('StoreB', {
extend : 'AbstractStore',
model : 'modelB'
});
StoreB will load the data all fine, but the associated model will be 'modelA' if I remove the 'me.proxy.model' part. I noticed that the Store class is being extended using prototype and all of the properties are stored on prototype. This is maybe the reason why they share properties.
Do they share the proxy instance ?
If a remove the Abstract layer, with the same config everything works fine.