1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    72
    Answers
    3
    Vote Rating
    2
    sephyroth69 is on a distinguished road

      0  

    Default Answered: Reference instance function/variable inside a store refresh event

    Answered: Reference instance function/variable inside a store refresh event


    I have a controller in which I initialize a store for my view. Now when the store is loaded, I want to apply a function to each record with the each method of the store, so I'm binding on refresh event (which is properly called), however, this does not point to the right scope and I don't this how to call a function of my controller singleton and reference a instance variable of my controller.
    Thanks for any pointer.
    Code:
    getMyStore:function () { // Method of my controller, loading the store from the launch method.
            return Ext.create('Ext.data.Store', {
                model:'My.model.Bean',
                sorters:'date',
                proxy:{
                    type:'ajax',
                    url:'app/resources/data/some_data.json',
                    reader:{
                        type:'json',
                        rootProperty:'root'
                    }
                },
                autoLoad:true,
                listeners:{
                    refresh: function(){
                        this.calcForEach(this); // This is the method of my controller
                        console.log('Store length : ' + store.getCount());
                    }
                }
            });
        }

  2. Code:
    listeners : {
        scope : this,
        refresh : function() {...} //scope is of this which should be the controller
    }

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,782
    Answers
    3465
    Vote Rating
    833
    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 first argument in a refresh event is the store.
    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.

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    72
    Answers
    3
    Vote Rating
    2
    sephyroth69 is on a distinguished road

      0  

    Default


    I'm looking for a pointer to my controller, not to my store...

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,782
    Answers
    3465
    Vote Rating
    833
    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


    Code:
    listeners : {
        scope : this,
        refresh : function() {...} //scope is of this which should be the controller
    }
    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.

  6. #5
    Sencha User
    Join Date
    Nov 2011
    Posts
    72
    Answers
    3
    Vote Rating
    2
    sephyroth69 is on a distinguished road

      0  

    Default


    Nice, I'll try that. Thanks !

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi