Hybrid View
-
10 Jan 2012 6:19 AM #1
WebStorage proxy can't deal with associated data
WebStorage proxy can't deal with associated data
REQUIRED INFORMATION
Ext version tested:- Touch 2.0PR3
- Chrome 17
- Safari 5.1.2
- 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); }});
-
10 Jan 2012 9:54 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,128
- Vote Rating
- 453
Do you have a test case?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Jan 2012 11:00 AM #3
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); }});
-
3 Feb 2012 6:39 PM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 5
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.
-
4 Feb 2012 2:25 AM #5
-
17 Feb 2012 3:34 PM #6
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.
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1370
in
2.1.


Reply With Quote

