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 - Services Team tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,292
    Vote Rating
    6
    Answers
    57
    tobiu will become famous soon enough

      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
    __________


    Sencha Inc
    Tobias Uhlig, Solutions Engineer

    Private Projects:

    S-CIRCLES Social Network Engine
    Commercial Theming for Ext JS 3 & 4

  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
    St. Louis, MO
    Posts
    33,624
    Vote Rating
    435
    Answers
    3106
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

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

Tags for this Thread