PDA

View Full Version : listeners on instance block execution on baseclass



marc123
3 Dec 2012, 8:55 AM
Hello,

I am working with an Ext Js 3.4 application and encounter an issue when listeners of a parent class don't get executed when an instance of that class has also listeners defined on them.

I have an instance data store like this;

application.store.status=new application.ColdFusionJsonStore({
....
})

the abstract class application.ColdFusionJsonStore is defined like this:

application.ColdFusionJsonStore = Ext.extend(Ext.data.Store,{
...
,listeners: {
load: function(Store, records, options){
...
})

Now when I _don't_ define listeners on the instance (application.store.status), the listeners on abstract class (application.ColdFusionJsonStore) get executed. That is behaviour as designed.
For this specific data store instance I want to add some extra options to the store so I defined a listener block on it with an load property:

application.store.status= new application.ColdFusionJsonStore({
,listeners: {
load: function(Store, records, options){
var defaultItem = new Store.recordType({SPOC_NL_STATUS_ID:'',SENT_STATUS_DESCRIPTION:'-- All --'}, 0);
Store.insert(0,defaultItem);
Store.commitChanges();
}
....
})

Now when I execute this code only the listeners I defined on the _instance_ (application.store.status) get executed but not the load listener that was defined on the abstract class. But I need that listener to execute as well so I tried to call it from the instance:

application.store.status= new application.ColdFusionJsonStore({
,listeners: {
load: function(Store, records, options){
this.superclass.load();
//existing code
....
})
but this doesn't work. this.superclass.load is undefined.

How can I add functionality to a data store instance _without_ overriding parent functionality?
Please note I am on Ext 3.4, I understood that Ext 4 has a totally different classsystem where this issue would be no issue at all.

Thanks,

Marc

warrean
4 Dec 2012, 4:22 AM
Can you maybe work with the 'beforeload'-event from a Store?

Also use the [code]-tag, much easier to read.

marc123
4 Dec 2012, 2:42 PM
No, it looks as if using a listener property on an instance blocks execution of the listeners on the baseclass.