Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1372 in a recent build.
  1. #1
    Sencha User luismerino's Avatar
    Join Date
    Oct 2011
    Location
    Berlin
    Posts
    46
    Vote Rating
    4
    luismerino is on a distinguished road

      0  

    Default JsonStore forces proxy type "Ajax" despite definitions in a new class

    JsonStore forces proxy type "Ajax" despite definitions in a new class


    REQUIRED INFORMATION




    Ext version tested:
    • Sencha Touch 2.0PR3


    Description:
    • A store that extends from JsonStore will be created with ajax proxy by default, ignoring any other proxy declaration made.


    Steps to reproduce the problem:
    • Create a store that extends from JsonStore
    • Add a proxy property with localstorage type for instance
    • Create an instance of this new store and retrieve its proxy "getProxy().type"


    The result that was expected:
    • "localstorage"


    The result that occurs instead:
    • "ajax"


    Test Case:


    Code:
        Ext.define('Pistachio.store.Events', {
            extend: 'Ext.data.JsonStore',
            storeId: 'Events',
            proxy: {
                type: 'localstorage',
                id: 'example-events'
            }
        });
    
    
        console.log(Ext.getStore('Events').getProxy().type) // outputs "ajax"



    Possible fix:
    • not provided

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


    Looking at the source for the JsonStore, the proxy is checked on the config so therefore if you wanted to override the functionality you would have to do this:

    Code:
    Ext.define('Pistachio.store.Events', {
        extend: 'Ext.data.JsonStore',
        
        constructor : function(config) {
            if (!config) {
                config = {};
            }
            
            Ext.applyIf(config, {
                type : 'localstorage',
                id   : 'example-events' //wouldn't use a set id unless you are only going to have one instance
            });
            
            this.callParent([config]);
        }
    });
    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.

  3. #3
    Sencha User luismerino's Avatar
    Join Date
    Oct 2011
    Location
    Berlin
    Posts
    46
    Vote Rating
    4
    luismerino is on a distinguished road

      0  

    Default


    Ok, but perhaps using JsonStorage defaults to ajax and it probably shouldn't, since AbstractStore does not nor Store itself. This, at the very least, leads to confusion.

    In any case, I am forced to use id I believe:

    Code:
    if (this.id === undefined) {
    Code:
    Ext.Error.raise("No unique id was provided to the local storage proxy. See Ext.data.proxy.LocalStorage documentation for details");
    }
    

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    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


    Yes you are forced to use id but if you have one set in the class definition then that id will be shared among all instances
    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.

  5. #5
    Sencha User luismerino's Avatar
    Join Date
    Oct 2011
    Location
    Berlin
    Posts
    46
    Vote Rating
    4
    luismerino is on a distinguished road

      0  

    Default


    True that. But that's not question. Now that you guys know what I mentioned above my job is done

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    This has been fixed as part of the Data Package cleanup and will be part of the next Touch 2.0 release. Thanks for the report again!