View Full Version : Adding a store listener in a controller

9 Sep 2011, 2:03 AM
Hey guys,

i try to add a listener for a store in a controller.

I tried this way:

Ext.define('gigadmin.store.MyStore', {
listeners: {
'beforeload': function(){
//call the function in the controller

So i want to call the function in my controller when the event is fired.

But i don't know how to do that :-(

Thanks for your help!

9 Sep 2011, 5:11 AM
Couple ways to do it but none directly within the control method call.

You can define the Store in the stores config of the controller and then in the init method, use the getter for that Store and use on() to place a listener on that Store.

Use the control method to get a reference of the widget using the Store. Then when that event fires, get the Store and put the listener on it then.

Downside to these two is that the listeners get placed on individual Store instances. It's not like using ComponentQuery in the control method where it will fire for any instance.