PDA

View Full Version : Cascading listener events



ctp
22 Oct 2010, 7:23 AM
Hi all,

I need some kind of access to an underlying event. In my case I'm populating a combo box with json data, so the JsonStore fires a load event when all data loaded. Now I need any access to this event within my combo itself to set one of the options automatically. How does this work in practice? How to access a JsonStore event within a ComboBox listener?

Condor
22 Oct 2010, 7:29 AM
You need to hook up your own listener to the store in one of the combobox events ('render'?).

ctp
22 Oct 2010, 7:39 AM
Hi Condor,

you mean not to define a listener within the store itself but reference the store's load event in combobox' listener? didnt find any doc about such listener cascades.

Condor
22 Oct 2010, 7:44 AM
The store load event is already hooked up by ComboBox to the onLoad method, so you could also use:

var combo = new Ext.form.ComboBox({
...
onLoad: function(){
// your code here
this.constructor.prototype.onLoad.apply(this, arguments);
}
});

ctp
22 Oct 2010, 9:00 AM
Sorry Condor for these newbie questions but how to reference the store's load event within onLoad? when does onLoad fire exactely? a simple onLoad: function() {console.log("foo")} shows me it reacts on combo clicks but how should the simple console.log be defined to show the message after the combo is populated?