dcoan
14 Sep 2010, 10:28 PM
Hello Great Minds of the Sencha forum,
Please help me to understand the error of my ways.
I have a grid extension which is working well.
Now, I'm working on creating a plugin for the grid.
In the grid I have:
initComponent : function(){
...
this.store = new Ext.data.Store({
.....
// store is configured
.....
});
this.store.on("metachange", this.onMetaChange, this); // setup an event handler when store meta changes
}, // eo grid's initComponent function
onMetaChange = function(store, meta){ // the handler for the metachange event
alert(1); // successfully fired when the metadata changes
} // eo grid's onMetaChange function
Then, in the plugin I have this:
init : function(grid) {
grid.onMetaChange = grid.onMetaChange.createInterceptor(function(store,meta){
alert(2); // should fire (but doesn't)
return true; // return true, so that the original function will fire
});// end of intercepting function
So, normally (ie when the plug in is not attached to the grid), when the store metadata changes the grid's onMetaChange function is fired and the alert says "1". This works fine.
But, when I add the plugin to the grid, I expect that the createInterceptor will fire, and I will get this:
Alert: 2 // fired by the intercepting function (created in the plugin)
Alert: 1 // fired by the original function (created in the grid)
But no matter what I've tried (and I've tried a bunch of things and read the API)... I always get "1". The interceptor never fires.
What am I missing?
Please help me to understand the error of my ways.
I have a grid extension which is working well.
Now, I'm working on creating a plugin for the grid.
In the grid I have:
initComponent : function(){
...
this.store = new Ext.data.Store({
.....
// store is configured
.....
});
this.store.on("metachange", this.onMetaChange, this); // setup an event handler when store meta changes
}, // eo grid's initComponent function
onMetaChange = function(store, meta){ // the handler for the metachange event
alert(1); // successfully fired when the metadata changes
} // eo grid's onMetaChange function
Then, in the plugin I have this:
init : function(grid) {
grid.onMetaChange = grid.onMetaChange.createInterceptor(function(store,meta){
alert(2); // should fire (but doesn't)
return true; // return true, so that the original function will fire
});// end of intercepting function
So, normally (ie when the plug in is not attached to the grid), when the store metadata changes the grid's onMetaChange function is fired and the alert says "1". This works fine.
But, when I add the plugin to the grid, I expect that the createInterceptor will fire, and I will get this:
Alert: 2 // fired by the intercepting function (created in the plugin)
Alert: 1 // fired by the original function (created in the grid)
But no matter what I've tried (and I've tried a bunch of things and read the API)... I always get "1". The interceptor never fires.
What am I missing?