1. #1
    Sencha Premium Member
    Join Date
    Nov 2008
    Posts
    27
    Vote Rating
    0
    mastachef is on a distinguished road

      0  

    Default How to bubble events from Store (revisited)

    How to bubble events from Store (revisited)


    Hello everyone. I tried to do some research on how to bubble an event from the Store and I came across this thread from the EstJS 4 forum - http://www.sencha.com/forum/showthre...Ext.data.Store

    With that, I tried to see if I can accomplish this in 3.2.1 and what I would to accomplish is to be able to bubble an event from the store after the records have been loaded.

    Here, I have extended the store with the event I need to fire after the records have been loaded.
    Code:
    // Extension of the Store
    Ext.ux.GridAwareStore = Ext.extend
    (
        Ext.data.Store, 
        {
            constructor: function(config){
                Ext.ux.GridAwareStore.superclass.constructor.apply(this, arguments);
                this.addEvents('actioncomplete');
                this.reader.readRecords =      this.reader.readRecords.createSequence(this.verifyResponse, this);
            },
            verifyResponse: function(o){
                console.log('got the load');
                this.fireEvent('actioncomplete');        
            },
            loadData : function(o, append){
                this.fireEvent('actioncomplete', this);
            },
            listeners: {
                storeloaded: function(r) {
                    this.enableBubble('actioncomplete');
                }
            }
        }
    );
    The issue on the Grid is that I am able to capture the event being fired from the Store only once (initial loading). After that, this section of code is never reached.
    Code:
    // GridPanel overridden
    Ext.override(Ext.grid.GridPanel, {
        bubbleEvents: ['actioncomplete'],
        initComponent: Ext.grid.GridPanel.prototype.initComponent.createSequence(function() {
                this.addListener('actioncomplete', function() {}, this);
                console.log('the grid has it');
                this.fireEvent('actioncomplete');
        })
    });
    The questions I have are how does one maintain passing the Store's data while bubbling the event and why is my listener only capturing the event once.

    Any help is greatly appreciated. Thank you.
    Last edited by mastachef; 3 Mar 2012 at 5:30 AM. Reason: clearer explaination

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,549
    Vote Rating
    873
    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


    The actioncomplete event on the grid is only going to fire once as it's in the initComponent which only fires once.
    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: 1

Tags for this Thread