View Full Version : Using Sencha.io with a remote store

18 Nov 2011, 4:22 AM

I'm pretty new to Sencha.io, but reading the documentation I thought it could help me in my project. Here's the situation : my app basically allows a manager to do CRUD operations on a product list. Currently, I load the product list from a remote store and anytime the manager adds, edits or deletes a product I have to make first a call to persist his changes in the remote store, then make a second call to reload the list.

Now, reading the Sencha.io documentation I was under the impression I could do this (let's suppose there is no internet access) : The manager would still be able to do any CRUD operations on the current store and the list would still be refreshed accordingly. If internet access was available again, all the CRUD operations would be mirrored on the remote store and the local store would be resynced to account for any changes made by other managers.

My problem right now is that I have absolutely no idea how to do this. To begin, I would like to be able to just load the remote store into the local one and populate the product list with the loaded items. The next step would be to start manipulating the local store and syncing it whenever an internet connection is available. Any idea how to do that ? :)

Here is my current store :

Ext.define('DM21.store.Products', {
extend: 'Ext.data.Store',
model: 'DM21.model.Product',

proxy: {
type: 'ajax',

url: 'app/remote/GetData.php',
reader: {
type: 'json',
root: 'products'

I load the store after the user logs in :

params: {
object: 'Product'

Thanks :)

19 Dec 2011, 1:23 PM

Create a second store, setting the proxy to 'syncstorage'...

proxy: {
type: 'syncstorage',
id: 'my_store_name',
key: 'my_sencha_username'

Then use your ajax proxy to load the data into the client, and then write it into your new sync store. Your data will be stored on the Sencha.io servers, and any clients that open the same named store will be kept in sync.