PDA

View Full Version : Steps and best ways for 'Ext.override'



Ronits
15 Oct 2012, 9:59 PM
Hi,
I would like to know the best way to override a method/function of a class, in the below mentioned scenario :
I need to override the reload() of store, because, I had faced some issues, trying to reload a buffered store.


Ext.override(Ext.data.Store, {

reload: function(options) {


I have put this in the
launch: function () { of app.js, which basically is the
Ext.application({
Is this correct way to do it ?

kevin.chen
17 Oct 2012, 2:09 PM
the override you used is for Ext 3.x, it is still working now for backward compatible

in 4.0


Ext.data.Store.override({
reload: function(options) {
...
}
});


in 4.1


Ext.define('mypatch', {
override: 'Ext.data.Store',
reload: function(options) {
...
}


})

skirtle
17 Oct 2012, 3:22 PM
The 4.1 approach can be a little confusing when you first see it. It looks like it is defining a new class rather than overriding the original class but it really does do the override on the original class.

The advantage of the 4.1 approach is that you can just include it in a requires block, you don't need to put it in the launch method or anything like that:


Ext.define('MyApp.data.Store', {
override: 'Ext.data.Store',
...
});


Ext.require('MyApp.data.Store');