Threaded 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); }});
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