1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    13
    Vote Rating
    0
    utkarshk.leeway is on a distinguished road

      0  

    Post 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

    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,669
    Answers
    130
    Vote Rating
    110
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      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
    __________

    S-CIRCLES Social Network Engine

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    13
    Vote Rating
    0
    utkarshk.leeway is on a distinguished road

      0  

    Default


    Thanks for your quick help.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Answers
    3470
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

Thread Participants: 2

Tags for this Thread