-
9 Nov 2011 9:38 AM #1
Answered: Firing an Event from a store to other components
Answered: Firing an Event from a store to other components
Hi team,
i would like to know that how can i initiate an event from store itself to the other components who wants to listen as data in store changes or loads.
One possible solution i know is using application level events however i am not able to initiate any application level call from mystore.js file example code given below
i can handle events raised by any other component.Code:Ext.define('NameSpace.store.myStore', { extend: 'Ext.data.Store', constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ autoLoad: true, storeId: 'someID', proxy: { type: 'ajax', url: 'http://www.someUrl.com', reader: { type: 'json', root: 'response' } } }, cfg)]); }, load: function() { this.application.fireEvent('storeisloaded'); } });
any input or suggestion is appreciated.
Regards
UT
Senior PHP Developer
Leewayhertz Technologies (http://www.leewayhertz.com)
-
Best Answer Posted by tobiu
Components are not meant to listen to events of other components, that is the job of the controller(s).
I recommend to read this guide:
http://docs.sencha.com/ext-js/4-0/#!...n_architecture
If you really want to, you can fire events on components though (like myPanel.fireEvent('foo')), but this messes up your code.
-
9 Nov 2011 10:21 AM #2Sencha - Services Team
- Join Date
- May 2007
- Location
- Munich (Germany)
- Posts
- 2,292
- Vote Rating
- 6
- Answers
- 57
Components are not meant to listen to events of other components, that is the job of the controller(s).
I recommend to read this guide:
http://docs.sencha.com/ext-js/4-0/#!...n_architecture
If you really want to, you can fire events on components though (like myPanel.fireEvent('foo')), but this messes up your code.
-
10 Nov 2011 2:35 AM #3
-
10 Nov 2011 5:28 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
- Answers
- 3106
Please note that this.control uses ComponentQuery and not everything is a component... Store is not a component. Anything that eventually extends Ext.Component can be used in conjunction with ComponentQuery.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote