1. #1
    Sencha Premium Member
    Join Date
    Jun 2008
    Posts
    51
    Vote Rating
    1
    mbajema is on a distinguished road

      0  

    Default Support for extraParams in Ext.data.DirectStore

    Support for extraParams in Ext.data.DirectStore


    extraParams is a config option of Ext.data.DirectProxy but is not passed from the Ext.data.DirectStore constructor meaning you can't use it unless you specify the proxy/reader configs separately. Yes you can call store.getProxy().setExtraParam after the store is created, but that doesn't work if you used autoLoad: true.

    I recommend adding it to Ext.data.DirectStore constructor like so:

    Code:
        constructor : function(config){
            config = Ext.apply({}, config);
            if (!config.proxy) {
                var proxy = {
                    type: 'direct',
                    reader: {
                        type: 'json'
                    }
                };
                Ext.copyTo(proxy, config, 'paramOrder,paramsAsHash,directFn,api,simpleSortMode,extraParams');
                Ext.copyTo(proxy.reader, config, 'totalProperty,root,idProperty');
                config.proxy = proxy;
            }
            this.callParent([config]);
        }
    Mark Bajema
    Youth Mentoring Software from Innovative Mentoring

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Boca Raton, FL
    Posts
    94
    Vote Rating
    1
    jimmifett is on a distinguished road

      0  

    Default


    I usually build my stores along these lines and have no problems:

    PHP Code:
                storeId        'foo',
                
    autoLoad    true,
                
    autoSync    true,
                
    pageSize    25,
                
    proxy        : {
                    
    type        'direct',
                    
    api            : {
                        
    create    Ext.emptyFn,
                        
    read    Ext.app.Components.foo.getBar,
                        
    update    Ext.emptyFn,
                        
    destroy    Ext.emptyFn
                    
    },
                    
    extraParams    : {
                        
    baz    0
                    
    },
                    
    reader    : {
                        
    type            'cfquery',
                        
    successProperty 'success',
                        
    messageProperty    'message'
                    
    },
                    
    writer    : {
                        
    type            'json',
                        
    writeAllFields    true
                    
    },
                    
    listeners    : {
                        
    exception    : function(proxyrequestoperationeOpts){
                            
    Ext.Msg.alert('foo'proxy.getReader().getMessage(proxy.getReader().rawData));
                        }
                    }
                },
                
    listeners    : {
                    
    load    : {
                        
    fn : function(scoperecordssuccessfuleOpts){
    //stuff
                        
    }
                    }
                } 
    and then later if I need to adjust extra params:

    store.proxy.extraParams.baz = someVal;

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2008
    Posts
    51
    Vote Rating
    1
    mbajema is on a distinguished road

      0  

    Default


    Ext.data.DirectStore is a convenience class. It would be more convenient if you could use extraParams with it. So instead of the following (modified from your example):
    Code:
    var store = Ext.create('Ext.data.Store', {
        storeId: 'foo',
        autoLoad: true,
        autoSync: true,
        pageSize: 25,
        proxy: {
            type: 'direct',
            api: {
                read: Ext.app.Components.foo.getBar
            },
            extraParams: {
                baz: 0
            }
        },
        reader: {
            type: 'json',
            successProperty: 'success',
            messageProperty: 'message'
        }
    });
    You could use:
    Code:
    var store = Ext.create('Ext.data.DirectStore', {
        storeId: 'foo',
        autoLoad: true,
        autoSync: true,
        pageSize: 25,
        api: {
            read: Ext.app.Components.foo.getBar
        },
        extraParams: {
            baz: 0
        },
        successProperty: 'success',
        messageProperty: 'message'
    });
    Obviously, it's not a big deal, but it does remove a few lines of code from potentially many store instances in an application.
    Mark Bajema
    Youth Mentoring Software from Innovative Mentoring

  4. #4
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Boca Raton, FL
    Posts
    94
    Vote Rating
    1
    jimmifett is on a distinguished road

      0  

    Default


    When ext.direct first came out, I played with convience of the direct stores, but was always running into problems, like this one, of something I thought should be there wasn't. I eventually moved to my current way, making what I want explicitly clear, especially if I need to swap out for a different underlying source. For the most part, my store code is now copy, paste, tweak for most of my projects

  5. #5
    Sencha - Ext JS Dev Team
    Join Date
    Jun 2011
    Location
    San Diego, CA
    Posts
    191
    Vote Rating
    37
    nohuhu has a spectacular aura about nohuhu has a spectacular aura about

      0  

    Default


    mbajema,

    Looks like a neat little feature. Thanks for suggestion.

    Regards,
    Alex.

Thread Participants: 2

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