1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    12
    Vote Rating
    0
    PJoe is on a distinguished road

      0  

    Default 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.

  2. #2
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,135
    Answers
    129
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    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).

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    12
    Vote Rating
    0
    PJoe is on a distinguished road

      0  

    Default


    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?

  4. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,135
    Answers
    129
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    You can do something like this:
    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();
    Hope it helps you out. I have used the same store with no problems. I keep switching out different proxies on it too.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar