Hybrid View

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    11
    Vote Rating
    0
    maxLodoss is on a distinguished road

      0  

    Default Unanswered: use syncstorage with Sensha Touch 2.

    Unanswered: use syncstorage with Sensha Touch 2.


    Hello, i have Ext.list associated with models whitch have syncstorage proxy type.
    Code:
        
    Ext.define('myApp.store.mystore', {
    
        extend  : 'Ext.data.Store',
        model   : 'myApp.model.mymodel',
        requires: ['myApp.model.mymodel'],
        storeId : 'storeid',
        sorters : 'somerecord',
        getGroupString: function(record) {
                               return record.get('somerecord')[0];
                           },
         autoLoad    : true
    });
    
    Ext.define("myApp.model.mymodel", {
        extend: "Ext.data.Model", 
        fields: [
            {name: "id", type: "string"},
            {name: "firstfieald", type: "string"},
            {name: "secondfieald", type: "string"}
        ],
        
            proxy: {
                id: 'proxyid',
                type: 'syncstorage',
                key: 'myproxykey'
            }
    });
    When I add record to my store then record shows in browser localstorage and store total count increment, but store data items array is empty.

    Please give me small work syncstorages example or tell me what i'm doing wrong.

  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


    @maxLodoss - That code looks right. How are you calling add()? And when are you calling sync()?

    John

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    11
    Vote Rating
    0
    maxLodoss is on a distinguished road

      0  

    Default


    I create instanse of my model
    Code:
    var myInstance = Ext.create('myApp.model.mymodel',{
                    ...
    		});
    
    myInstance.save();
    After this code I can see my new instance model in browser localstorage .

    Then I restart my application and store should load data from localstorage (becouse autoload : true) and it try do it, but store data items array is empty.

    I tried find solution in src, and i think problen in
    sencha-io-debug.js read: function(operation, callback, scope)
    line 1986
    becouse operation.id is undefined

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

      0  

    Default


    Typically you call sync() after save or add to get the data actually written to disk.

    John

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    11
    Vote Rating
    0
    maxLodoss is on a distinguished road

      0  

    Default


    st2 documentation http://docs.sencha.com/touch/2-0/#!/...y.LocalStorage
    Show that we can use store.add() + store.sync() or modelinstance.save() , but first solution doesn't work for me.

Thread Participants: 1