1. #1
    Sencha User DrunkenBeard's Avatar
    Join Date
    May 2011
    Posts
    55
    Answers
    2
    Vote Rating
    -2
    DrunkenBeard has a little shameless behaviour in the past

      0  

    Default Unanswered: Using Sencha.io with a remote store

    Unanswered: Using Sencha.io with a remote store


    Hello,

    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 :

    Code:
    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 :

    Code:
    productsStore.load({            
        params: {
            object: 'Product'
        }
    });
    Thanks

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Posts
    107
    Answers
    30
    Vote Rating
    -1
    merrells is an unknown quantity at this point

      0  

    Default


    Hello,

    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.

    John

Thread Participants: 1