I wanted to check the saved record from the local storage and authenticate the record with the server. I tried to change the store proxy using the function setProxy. First time when i call setProxy on the store it works fine however when i call it second time with a different Proxy, it throws error "Cannot call method 'getRecords' of undefined". Below is the logic.

localProxy = this.local = Ext.create('Ext.data.proxy.LocalStorage', {id:'credentials'});
store.setProxy(localProxy);
...

serverProxy = Ext.create('Ext.data.proxy.Ajax', { url: 'xxx',
type:'json',
});

store.setProxy(serverProxy);
on executing this statement, it throws error "Cannot call method 'getRecords' of undefined"

Any help is much appreciated.

Thanks,
John