1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    26
    Vote Rating
    2
    rossmurphy is on a distinguished road

      0  

    Default Answered: Proxy in Model vs. Store

    Answered: Proxy in Model vs. Store


    Does anyone know the difference between using a proxy in a model vs. using a proxy in a store?

    Code:
    Ext.regModel('User', {
        fields: ['id', 'name'],
        hasMany: {model: 'Order', name: 'orders'},
        proxy: {
            type: 'ajax',
            url : 'src/demos/data/userData.json'
        }
    });

  2. Technically there really isn't a difference. The store will look for the proxy config on itself and if none is present look for it on the model. If you want to use Models by themselves (like for forms) then having the proxy on the model will allow you to still use the proxy.

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


    Technically there really isn't a difference. The store will look for the proxy config on itself and if none is present look for it on the model. If you want to use Models by themselves (like for forms) then having the proxy on the model will allow you to still use the proxy.
    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
    Dec 2011
    Posts
    26
    Vote Rating
    2
    rossmurphy is on a distinguished road

      1  

    Default


    It would be nice if the documentation explained things like this

  5. #4
    Sencha Premium Member intellix's Avatar
    Join Date
    Mar 2012
    Location
    UK + Malta
    Posts
    263
    Answers
    5
    Vote Rating
    18
    intellix will become famous soon enough

      0  

    Default


    Quote Originally Posted by rossmurphy View Post
    It would be nice if the documentation explained things like this
    Seconded

  6. #5
    Sencha User
    Join Date
    Jun 2013
    Posts
    45
    Answers
    1
    Vote Rating
    4
    AdamMarshall is on a distinguished road

      0  

    Default


    Thirded

  7. #6
    Sencha Premium Member
    Join Date
    Jul 2014
    Location
    Pune, India
    Posts
    6
    Vote Rating
    0
    snehalmasne is on a distinguished road

      0  

    Default


    I found it in the documentation of Sencha App Architecture Part 2


    Use proxies for models:

    It is generally good practice to do this as it allows you to load and save instances of this model without needing a store. Also, when multiple stores use this same model, you don’t have to redefine your proxy on each one of them.


    Use proxies for stores:

    In Ext JS 4, multiple stores can use the same data model, even if the stores will load their data from different sources. In our example, the Station model will be used by the SearchResults and the Stations store, both loading the data from a different location. One returns search results, the other returns the user’s favorite stations. To achieve this, one of our stores will need to override the proxy defined on the model.


    Regards,
    Snehal Masne
    Techproceed.com
    Thanks!
    Snehal Masne
    www.TechProceed.com