Answered: Save the Store data to LocalSotrage !

hi,

I am new to sencha touch, I was beating my head against the wall for the last couple of days to solve this problem without any result .

I have a storage named articles that gets its data from a server (using an ajax proxy), and I pass this store to an ArticleList view that displays it, and this works as wanted but now i want the data of "store.Articles" to be saved to LocalStorage automatically, and when I reload my app i want the view to use the data stored in the localStorage in stead of loading it again from the server.

You could change the store to local storage. Then, write a nice piece of script which 1) reads al records which has to be inserted (in JSON format for example) 2) insert those records into the store and 3) saves the date/time of last synchronization, which can be used for further synchronisation.

Make sure that (in the model) you explicitly specify the identifier (UUID) and idproperty, otherwise local storage will not work correctly.

So change the proxy in your store to:

PHP Code:

proxy: { type: 'localstorage', id: 'Articles' }

Add those line in your model's config:

PHP Code:

idProperty: 'appid',identifier: 'uuid'

You will have to think about the synchronization part yourself, as that depends on what functionality you want.

You could change the store to local storage. Then, write a nice piece of script which 1) reads al records which has to be inserted (in JSON format for example) 2) insert those records into the store and 3) saves the date/time of last synchronization, which can be used for further synchronisation.

Make sure that (in the model) you explicitly specify the identifier (UUID) and idproperty, otherwise local storage will not work correctly.

So change the proxy in your store to:

PHP Code:

proxy: { type: 'localstorage', id: 'Articles' }

Add those line in your model's config:

PHP Code:

idProperty: 'appid',identifier: 'uuid'

You will have to think about the synchronization part yourself, as that depends on what functionality you want.