-
22 Aug 2012 7:00 AM #1
Unanswered: Usage of store/proxy in offline mode
Unanswered: Usage of store/proxy in offline mode
I have been using store/model/proxy to fetch data from the server - this works fine.
My requirement is to store this data in a sqllite database on the device for offline use. Currently my store/proxy is configured to fetch/send data to from/to a server. How can I use the same to store/fetch data from the local sqllite database in offline mode? Do I have to define a new set of models/stores?
Can anyone please provide some pointers as I am trying to absorb the "offline" mode.
Thanks.
-
22 Aug 2012 3:06 PM #2
You will have to change the Store's Proxy. Also, if the SQL database uses different parameters and fields then you will have to change the Model as well. The Store has methods to do that.
In my opinion, I would use the same Store if it involves the same set of data (as in the same Model).
-
23 Aug 2012 1:20 PM #3
So I guess you are suggesting the use the same store and could this be done something like this?
If (connected)
{
myStore.setProxy(OnLineServerDetails)
}
else
{
myStore.setProxy(LocalStorageProxy)
}
Does any one has success stories in using the same stores/models this way? Can you share any code samples?
-
23 Aug 2012 2:10 PM #4
You can do something like this:
Hope it helps you out. I have used the same store with no problems. I keep switching out different proxies on it too.Code:var onlineProxy = { //online configs }; var offlineProxy = { //offline configs }; Ext.create('Ext.data.Store', { storeId: 'datastore', proxy: connected ? onlineProxy : offlineProxy, model: connected ? 'onlineModel' : 'offlineModel', //if necessary autoLoad: false, listeners: { load: function(store, records) { //do your thing on load } } }; Ext.getStore('datastore').load();


Reply With Quote