1. #1
    Ext User
    Join Date
    Jul 2009
    Posts
    75
    Vote Rating
    1
    douggiefox is on a distinguished road

      0  

    Default Store add listener

    Store add listener


    Hi

    I'm trying to update records in a store once they've been added to the store. I've put code in an "add" listener like this:

    Code:
            new Ext.data.GroupingStore({
                storeId: 'memberStore',
                reader: new Ext.data.JsonReader({fields: Member}),
                sortInfo: {field: 'name', direction: 'ASC'},
                listeners: {
                    'add' : {
                        fn: function(store, record, index) {
    
                            Ext.each(store.getRange(), function(rec){
    
                                if(!rec.get('planId')){
                                    rec.set('plan', 'Plop');
                                    rec.set('planId', 1);
                                }
                                
                            });
    
                        }
                    }
                }
            });
    But i'm not having any success. The grid that the store belongs to ends up with an empty row and the row that's been added. Anyone any ideas how to accomplish this?

    Best

    DF

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,501
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      -2  

    Default


    So what EXACTLY are the params passed to an add event handler?

  3. #3
    Ext User
    Join Date
    Jul 2009
    Posts
    75
    Vote Rating
    1
    douggiefox is on a distinguished road

      0  

    Default


    Hi Animal

    @param {Store} this
    @param {Ext.data.Record[]} records The array of Records added
    @param {Number} index The index at which the record(s) were added

    I spotted I got record and records incorrect.

    So I updated my code to:

    Code:
    Ext.each(records, function(rec){
    
                                if(!rec.get('planId')){
                                    rec.set('plan', 'Plop');
                                    rec.set('planId', 1);
                                }
                                
                            });
    But I'm still getting the rogue blank row.

    Are you suggesting I've got the add listener params wrong?

    Best

    DF

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,501
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      -2  

    Default


    no more avoidance possible.

    you'll have to debug.

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