PDA

View Full Version : [4.1b1]Ext.override doesn't work correctly



kof720551
15 Jan 2012, 8:13 PM
I refer to Ext.data.AbstractStore constructor,and override add a line test code "alert('123');".
This worked correctly in version 4.0.2a,but can't worked in 4.0.7/4.1pr/4.1b1.


Ext.onReady(function () {
Ext.override(Ext.data.AbstractStore, {
constructor: function (config) {
//test code
alert('123');

var me = this,
filters;

Ext.apply(me, config);
me.removed = [];
me.mixins.observable.constructor.apply(me, arguments);
me.model = Ext.ModelManager.getModel(me.model);
Ext.applyIf(me, {
modelDefaults: {}
});
if (!me.model && me.fields) {
me.model = Ext.define('Ext.data.Store.ImplicitModel-' + (me.storeId || Ext.id()), {
extend: 'Ext.data.Model',
fields: me.fields,
proxy: me.proxy || me.defaultProxyType
});
delete me.fields;
me.implicitModel = true;
}
if (!me.model && me.useModelWarning !== false) {
if (Ext.isDefined(Ext.global.console)) {
Ext.global.console.warn('Store defined with no model. You may have mistyped the model name.');
}
}
me.setProxy(me.proxy || me.model.getProxy());
me.proxy.on('metachange', me.onMetaChange, me);
if (me.id && !me.storeId) {
me.storeId = me.id;
delete me.id;
}
if (me.storeId) {
Ext.data.StoreManager.register(me);
}
me.mixins.sortable.initSortable.call(me);
filters = me.decodeFilters(me.filters);
me.filters = new Ext.util.MixedCollection();
me.filters.addAll(filters);
}
});
Ext.define('Sharing.store.CamStore', {
extend: 'Ext.data.Store',
model: 'Sharing.model.CamModel',
data: [
{ "CamID": "1", "CamValue": "1" },
{ "CamID": "2", "CamValue": "2" },
{ "CamID": "3", "CamValue": "3" },
{ "CamID": "4", "CamValue": "4" },
{ "CamID": "5", "CamValue": "5" },
{ "CamID": "6", "CamValue": "6" },
{ "CamID": "All", "CamValue": "0" }
]
});

Ext.create('Sharing.store.CamStore');});

mitchellsimoens
16 Jan 2012, 8:58 AM
You should use Ext.define for overrides:


Ext.define('Override.data.AbstractStore', {
override : 'Ext.data.AbstractStore',

constructor : function(config) {...}
});

This allows to load the file dynamically if you setup a path for the Override namespace. You can call the parent code via this.callOverridden(arguments);