Results 1 to 4 of 4

Thread: Firing an Event from a store to other components

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    13
    Vote Rating
    0
      0  

    Post 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

    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');        
      }
    });
    i can handle events raised by any other component.

    any input or suggestion is appreciated.

    Regards
    UT
    Senior PHP Developer
    Leewayhertz Technologies (http://www.leewayhertz.com)

  2. 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.

  3. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,748
    Answers
    130
    Vote Rating
    128
      0  

    Default

    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.
    Best regards
    Tobias Uhlig

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    13
    Vote Rating
    0
      0  

    Default

    Thanks for your quick help.

  5. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,422
    Answers
    3901
    Vote Rating
    1271
      0  

    Default

    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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •