Need some help to save Ext.Store data in localstorage which connects to extrenal system (using rest webservice api).
Printable View
Need some help to save Ext.Store data in localstorage which connects to extrenal system (using rest webservice api).
you will need to download the data into the ajax store and then move the same into the offline store once the the online store is loaded
In the example below the inv.models.NewsData is my model and should me a model for both online and offline store.
Also your component should point to the the offlineStore.
Code:
inv.stores.NewsData = new Ext.data.Store({
model: 'inv.models.NewsData',
proxy: {
type: 'scripttag',
url: 'http://query.yahooapis.com/v1/public/yql',
extraParams: { format: 'json' },
reader: {
root: 'query.results.Results.RNSSummaries.RNSSummary'
}
}});
this.offlineStore= new Ext.data.Store({
model: 'inv.models.NewsData',
proxy: new Ext.data.LocalStorageProxy({
id:'data',
proxy:{idProperty:'RNSId'}
}),
autoLoad: true,
autoSave: true
});
this.inv.stores.NewsData.on('load',function(store,records,opts){
console.log("load from online");
this.offlineStore.proxy.clear();
this.inv.stores.NewsData.each(function (record){
var iconEach = this.offlineStore.add(record.data)[0];
},this);
this.offlineStore.sync();
console.log("loaded from online");
},this);