Hybrid View

    Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1370 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

      2  

    Default WebStorage proxy can't deal with associated data

    WebStorage proxy can't deal with associated data


    REQUIRED INFORMATION

    Ext version tested:
    • Touch 2.0PR3
    Browser versions tested against:
    • Chrome 17
    • Safari 5.1.2
    Description:
    • WebStorage proxies don't use their reader/writer instances, therefore associated data is left out when using these types of proxy.
    Code:
    // Product Model
    Ext.define('Product', {
        fields: [
            {name: 'pid', type: 'int'},
            {name: 'name', type: 'string'}
        ],
        associations: [{
            type: 'belongsTo',
            model: 'Category'
        }]
    });
    
    
    // Category Model
    Ext.define('Category', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'id', type: 'int'},
            {name: 'name', type: 'string'}
        ],
        proxy: {
            type: 'localstorage',
            id  : 'my-categories'
        },
        hasMany: {
            model: 'Product',
            name : 'products',
            filterProperty: 'pid',
            proxy: {
                type: 'localstorage',
                id  : 'products'
            }
        }
    });
    
    
    // Categories Store
    Ext.define('Categories', {
        extend: 'Ext.data.Store',
        model: 'Category',
    });

    Code:
    var c = new Categories();
    c.loadData([
        {
            id: 1,
            name: 'First Category',
            products: [
                {
                    pid: 1,
                    name: 'First Product'
                }
            ]
        }
    ]);
    
    
    c.sync();

    Refresh browser window, then:


    Code:
    var c = new Categories();
    c.load({success: function(records){ console.log(records); }});

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


    Do you have a test case?
    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


    Code:
    // Product Model
    Ext.define('Product', {
        fields: [
            {name: 'pid', type: 'int'},
            {name: 'name', type: 'string'}
        ],
        associations: [{
            type: 'belongsTo',
            model: 'Category'
        }]
    });
    
    
    // Category Model
    Ext.define('Category', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'id', type: 'int'},
            {name: 'name', type: 'string'}
        ],
        proxy: {
            type: 'localstorage',
            id  : 'my-categories'
        },
        hasMany: {
            model: 'Product',
            name : 'products',
            filterProperty: 'pid',
            proxy: {
                type: 'localstorage',
                id  : 'products'
            }
        }
    });
    
    
    // Categories Store
    Ext.define('Categories', {
        extend: 'Ext.data.Store',
        model: 'Category',
    });

    Code:
    var c = new Categories();
    c.loadData([
        {
            id: 1,
            name: 'First Category',
            products: [
                {
                    pid: 1,
                    name: 'First Product'
                }
            ]
        }
    ]);
    
    
    c.sync();

    Refresh browser window, then:


    Code:
    var c = new Categories();
    c.load({success: function(records){ console.log(records); }});

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

      0  

    Default


    Hi,

    Thanks for the great test case. We are still discussing internally what the best way would be to implement associations in combination with LocalStorage. Unfortunately this will probably not make it into the next beta release, but we are still hoping on getting this to work before Touch 2.0 GA.

    Just wanted to inform you that we are aware of this issue and to not expect this to work in the next beta release.

  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


    Quote Originally Posted by TommyMaintz View Post
    Hi,

    Thanks for the great test case. We are still discussing internally what the best way would be to implement associations in combination with LocalStorage. Unfortunately this will probably not make it into the next beta release, but we are still hoping on getting this to work before Touch 2.0 GA.

    Just wanted to inform you that we are aware of this issue and to not expect this to work in the next beta release.
    Thanks for the info. I look forward to see the chosen solution.

  6. #6
    Sencha User
    Join Date
    Dec 2011
    Posts
    11
    Vote Rating
    0
    spoussa is on a distinguished road

      0  

    Default Update

    Update


    Hi,

    Any update to the potential resolution (associations and local-storage)?

    If not available in final release, what is the recommended way of saving associations locally? Note, I'd like to use SQL but the author has not fixed the package for ST2 so can't count on that.