Results 1 to 3 of 3

Thread: Proxy in Model with extraParams

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    53
    Answers
    3

    Default Proxy in Model with extraParams

    Hi,

    I have moved all my proxy definitions to my Model Base class because I am saving some Model instances directly.

    This works great and all my stores are using the proxies defined in the given Models.

    But now if I try to set some extraParams in my viewModel defining the stores is not working any more. Do I have to do it in a different way? It was working with the proxy defined in the store itself.

    https://fiddle.sencha.com/#fiddle/1dja

  2. #2
    Sencha User
    Join Date
    May 2012
    Posts
    53
    Answers
    3

    Default

    Ok it seems to be solved

    Overriding the applyProxy method of my BaseStore does the trick.
    But I had to create a new proxy instance otherwise the model proxy will be overriden.

    Code:
    Ext.define('xxx.store.BaseStore', {    extend : 'Ext.data.Store',
    
    
        listeners : {
            load : function(store) {
                console.log(store);
            }
        },
    
    
        applyProxy : function(proxy) {
            var model = this.getModel();
    
    
            if (proxy !== null) {
                if (proxy) {
                    if (proxy.isProxy) {
                        proxy.setModel(model);
                    } else {
                        if (Ext.isString(proxy)) {
                            proxy = {
                                type : proxy,
                                model : model
                            };
                        } else if (!proxy.model) {
                            proxy = Ext.apply({
                                model : model
                            }, proxy);
                        }
    
    
                        proxy = Ext.createByAlias('proxy.' + proxy.type, proxy);
                        proxy.autoCreated = true;
                    }
                } else if (model) {
                    
                    modelProxy = model.getProxy();
                    proxy = Ext.createByAlias('proxy.' + modelProxy.type, modelProxy.getConfig());
                    proxy.extraParams = Ext.apply({}, modelProxy.extraParams, this.extraParams);
                    proxy.autoCreated = true;
                    
                }
    
    
                if (!proxy) {
                    proxy = Ext.createByAlias('proxy.memory');
                    proxy.autoCreated = true;
                }
            }
    
    
            return proxy;
        }
    
    
    });

  3. #3
    Sencha Premium User wemerson.januario's Avatar
    Join Date
    Nov 2008
    Location
    Goiânia - GO, Brazil
    Posts
    903
    Answers
    15

    Default

    Be carefull while defining proxy on model. When you define it on model classes and set an extraParam on the proxy. All Stores that use this model will be affected.

    If I were you, I would define all proxy on store, or both (store.model repeated)
    Wemerson Januario @JanuarioCoder
    Novanti Tecnologia, Sencha MVP/ Ext JS Consultant
    ____________________________________________
    Hire me on UpWork:

    GitHub
    https://github.com/wemersonjanuario

    Treinamento e Consultoria Ext JS. QUALIFIQUE-SE JÁ!

Similar Threads

  1. Proxy extraParams
    By hugodelgado in forum Ext: Q&A
    Replies: 4
    Last Post: 1 Jul 2015, 4:23 AM
  2. Replies: 9
    Last Post: 17 Nov 2014, 11:50 PM
  3. How to reset the extraParams from a proxy
    By axe312 in forum Sencha Touch 2.x: Q&A
    Replies: 3
    Last Post: 10 Nov 2013, 11:30 PM
  4. Proxy extraParams not applied
    By jakobgrannas in forum Sencha Touch 2.x: Q&A
    Replies: 2
    Last Post: 8 Feb 2012, 2:10 AM
  5. Add ExtraParams to Proxy
    By TiloS in forum Ext: Discussion
    Replies: 0
    Last Post: 20 Jul 2011, 10:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •