WebStorage proxy can't deal with associated data
REQUIRED INFORMATION
Ext version tested:Browser versions tested against: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); }});