PDA

View Full Version : read Local Storage Proxy after Page Refresh



irfaniqbal
25 Mar 2011, 9:11 AM
Hi all,
I am using LocalStorageProxy to store user related data in my app. I have successfully store the User data in LocalStorage. and here is the code.



var createLocalUserStore = function() {
Ext.regModel("LocalUser", {
fields: [
{name: 'session_id', type: 'string'},
{name: 'uuid', type: 'string'},
{name: 'id', type: 'string'}

],
proxy: {
type: 'localstorage',
id: 'userLocalStore'
}
});
var userStore = Ext.getStore('Users').getAt(0);

Application.stores.localUserStore = new Ext.data.Store({
storeId: 'localUserStore',
model: 'LocalUser'
});
Application.stores.localUserStore.clearData();

var userData = Ext.ModelMgr.create({
uuid: userStore.data.uuid,
session_id: userStore.data.session_id,
id: userStore.data.id
},
'LocalUser'
);
Application.stores.localUserStore.add(userData)
Application.stores.localUserStore.sync();
};


after storing data i m reading stored data like this:


Application.stores.localUserStore.read({
scope: this,
callback: function(rec){
console.log(rec)
}
});

but when i refresh page the Application.stores.localUserStore will become undefined.
my question is, how can i read Local Storage data after browser page refresh. Although, browser keep showing stored data after page refresh.
25347

yanhsy
2 Jan 2012, 7:00 PM
I have the same issue, can anyone help me. thanks!