Results 1 to 10 of 24

Thread: WebStorage proxy can't deal with associated data

Hybrid View

Previous Post Previous Post   Next Post Next Post
    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
      2  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Do you have a test case?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User luismerino's Avatar
    Join Date
    Oct 2011
    Location
    Berlin
    Posts
    46
    Vote Rating
    4
      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
    11
      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
      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
      0  

    Default 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.

Posting Permissions

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