1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    12
    Answers
    2
    Vote Rating
    2
    talwinder is on a distinguished road

      0  

    Default Unanswered: How to sync store after model setData()

    Unanswered: How to sync store after model setData()


    I am using a local storage proxy.

    I want to create a record if it doesn't exist in the store, which works correctly and is persisted properly as well but when I update a record using setData(newData) and then call sync() it doesn't persist and the data is set back to what it was called the store.add(). I tried to call setDirty() on the record but then when I call sync(), I get an error:
    Uncaught TypeError: Cannot read property 'isModel' of undefined

    If I instead set a single property such as first name by calling set('FirstName','test') and then call sync(), it persists properly and doesn't throw an error even when I call setDirty().

    Code:
                   var clientstore = Ext.getStore('clientstore');
    
                    /* findRecord( fieldName, value, [startIndex], [anyMatch], [caseSensitive], [exactMatch] ) */
    
    
                    var client = clientstore.findRecord('ID',responseData.Client.ID, 0, false, false, true);
                    if(!client)  {
                        client = Ext.create('dermix.model.Client', responseData.Client);
                        clientstore.add(client);
                    }
                    else{
                        client.setData(responseData.Client);
                        //client.set('FirstName','test');
                        client.setDirty();
                    }
                    
                    clientstore.sync();
                    console.log(clientstore);

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    There is an open bug that if you have a value for the idProperty field then it won't sync the data correctly to localstorage.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    12
    Answers
    2
    Vote Rating
    2
    talwinder is on a distinguished road

      0  

    Default


    Thanks Mitchell, could you provide a link to the bug tracker? In the meanwhile, anyone trying to do something similar to setData() can use set() and traverse through all the attributes like this:

    Code:
                       for (var prop in responseData.User) {
                            if (responseData.User.hasOwnProperty(prop)) {
                                var newVal = responseData.User[prop];
                                user.set(prop,newVal);       
                            }
                        }

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."