1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    50
    Vote Rating
    -1
    Seb_ST is an unknown quantity at this point

      0  

    Default Problem with local storage when using sync()

    Problem with local storage when using sync()


    Hi,

    I have a problem similar to those discussed in the following threads : here and here. However I wasn't able to solve my issue reading its.

    I have a store for which I'm using a localstorage proxy and the sync() method seems to work properly when I am adding an object to the store, but not when I am modifying one.
    I've tried to change the way I handle the idProperty in the model. I've tried to remove the idProperty and much more, but I am stuck there.

    Can someone help me ?

    Model :
    Code:
    Ext.define("CharacterSheet.model.Perso", {   
        extend: "Ext.data.Model",
        requires: ['Ext.data.identifier.Uuid'],
        config: {
            identifier: 'uuid',
            idProperty: 'id',
            fields: [
                { name: 'id', type: 'auto' },
            { name: 'nom', type: 'string' },
            { name: 'campagne', type: 'string' },
                { name: 'langue', type: 'string', defaultValue: 'english'},
                { name: 'race', type: 'int', defaultValue: 1 },
            { name: 'PH_opt', type: 'boolean', defaultValue: 'false'},
                { 
            name: 'typ_taille',
            type: 'int',
            convert: function(v, record) {
                var races = Ext.getStore("Races");
                var ra = record.get('race');
                if (Ext.isEmpty(ra)) {ra = 1;}
                return races.getById(ra).get('taille');
            }
        }],
        }
    });
    Store :
    Code:
    Ext.define("CharacterSheet.store.Persos", {    
      extend: "Ext.data.Store",
       requires: "Ext.data.proxy.LocalStorage",
        config: {
            model: "CharacterSheet.model.Perso",
            proxy: {
                type: 'localstorage',
                id: 'perso-store'
            },
        sorters: [
            {property: 'campagne', direction: 'ASC'},
            {property: 'nom', direction: 'ASC'}
        ],            
        grouper: {
                sortProperty: "campagne",
                direction: "ASC",
                groupFn: function (record) {
                return record.get('campagne');
             }
            }
        }
    });
    Code working :
    Code:
    var newPerso = Ext.create("CharacterSheet.model.Perso", {
                campagne: 'test' ,
                nom: 'Seb'
    });
    
    var persosStore = Ext.getStore("Persos");
    persosStore.add(newPerso);
    persosStore.sync();
    Code not working : it actually updates my store but these updates don't survive a refresh
    Code:
    var persos = Ext.getStore("Persos");
    var options = this.getOptions();
    var newValues = options.getValues();
    nb = persos.getCount();
    for (ii = 0 ; ii < nb ; ii++) {
        ppp = persos.getAt(ii);
        ppp.set("langue", newValues.langue);
        ppp.set("PH_opt", newValues.PH);
    }
    persos.sync();

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    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

      0  

    Default


    Have you inspected what the localstorage looks like? Is it making it to the 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
    Dec 2012
    Posts
    50
    Vote Rating
    -1
    Seb_ST is an unknown quantity at this point

      0  

    Default


    I can see that the fields have been modified in the localstorage. Even after refreshing the localstorage still show the records as I expect them to, meaning the changes are still appearing. But when I try to get the field I've modified with a code such as "mystore.getAt(0).get('field')" it returns the previous value. And it didn't before refreshing.

  4. #4
    Sencha User
    Join Date
    Dec 2012
    Posts
    50
    Vote Rating
    -1
    Seb_ST is an unknown quantity at this point

      0  

    Default


    Anyboby ?

Thread Participants: 1

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..." hd porno faketaxi