-
12 Dec 2006 9:40 AM #1
datachanged event no workie for me.
datachanged event no workie for me.
Im trying to add a listener to my dataModel when it's reloaded with new data. But it doesn't seem to fire.
I'm just trying to fire a simple alertCode:var dataModel; this.dataModel = new YAHOO.ext.grid.XMLDataModel(schema); this.dataModel.onLoad.subscribe(this.onLoad.createDelegate(this)); this.dataModel.addListener('datachanged',this.dataChanged);
I"m trying to call the method after I reload the data using :Code:dataChanged : function(){ alert('rows:' + this.dataModel.getRowCount()) },
And another thing. If I put an alert() in 'clearIndicator', it does not fire. Why is this?Code:search : function(e){ getEl('load-ind').show(); var params = {"list" : "New%20RFC's","keyField":"SVP%5Fx0020%5FApprover","query": e}; this.dataModel.load(...,,this.clearIndicator);
Code:clearIndicator : function(file){ getEl('load-ind').hide(); alert('dataLoaded'); },
-
12 Dec 2006 9:49 AM #2
You are looking for the 'load' event, not datachanged. I don't think datachanged is ever fired internally, it's there for subclasses to have a way to notify observers (like the grid) that the entire data has changed and needs to be rerendered (for example if you overwrite the "data" internal variable).
An XHR load fires a sequence of events - rowsdeleted, rowsinserted and then load.
-
12 Dec 2006 9:57 AM #3
Thanks Jack.
I did actuall try 'load', but I was using:
this.dataModel.addListener('load',this.onLoad);
but if I use:
this.dataModel.addListener('load',this.onLoad.createDelegate(this));
it works. No sure why the first doesn't.
-
12 Dec 2006 10:03 AM #4
The best way is:
this.dataModel.on('load',this.onLoad, this, true);
This way you only bind the scope once (I also like the shorter "on").
-
12 Dec 2006 11:10 AM #5
I've been tring to explain this to my colleague who I have trying to create a Date/time input widget+JSP tag.
Originally Posted by donalconlon
Think of the function parameter as being a C function pointer. All the addListener function receives is a function pointer. It has no concept of what the "this" should be at the time in the future that that function will be called. By default, in browsers it is the "window" object.
That's why the next parameter to addListener is "scope", and the next again is override. That means override the default scope with the passed scope.
createDelegate is another way to bind a scope to a function.
Similar Threads
-
how to stop click event when having dblclick event
By seldon in forum Ext 1.x: Help & DiscussionReplies: 5Last Post: 8 Nov 2011, 12:31 AM


Reply With Quote