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

      0  

    Default Answered: Cant get data from data.proxy.localstorage

    Answered: Cant get data from data.proxy.localstorage


    Hi,

    I'm trying to use localstorage proxy for my models, but for some reason after each page refresh I have empty data.
    I'm debuging in google chrome + ripple, and inside the "Storage" tab, I can see all data I saved. But when I trying to read it - data is empty.

    Here the code:

    controllers/Main.js:
    Code:
    launch: function() { 
    
     var optionsStore = Ext.getStore('optionsStore'),
        currentType = optionsStore.getById('type'); // Is null :( I event can't call .get() because it is null. 
    }
    Saving:
    Code:
    optionsStore.setData([{
            key: 'type',
            value: 'posts'
    }]);
    Reading after saving is ok.

    Store and model:
    Code:
    Ext.define('PM.model.Option', {
      extend: 'Ext.data.Model',
      requires: ['Ext.data.proxy.LocalStorage'],
      config: {
        fields: [
          { name: 'value', type: 'auto'}
        ],
        idProperty: 'key',
        proxy: {
          type: 'localstorage',
          id: 'options'
        }
      }
    });
    
    
    Ext.define('PM.store.Options', {
      extend: 'Ext.data.Store',   
      config: {
        model: 'PM.model.Option',
        storeId: 'optionsStore',
        autoSync: true
      }
    });

    Maybe I miss some addiitonal initialization code?

    Thanks and sorry for my bad english

  2. Can you let your store load the data at first?
    Code:
    var optionsStore = Ext.getStore('optionsStore'),
        currentType;
    console.info(optionsStore.isLoaded());
    optionsStore.load(function(){
        currentType=optionsStore.getById('type');
    })

  3. #2
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Can you let your store load the data at first?
    Code:
    var optionsStore = Ext.getStore('optionsStore'),
        currentType;
    console.info(optionsStore.isLoaded());
    optionsStore.load(function(){
        currentType=optionsStore.getById('type');
    })
    I write English by translator.

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    11
    Vote Rating
    0
    josser is on a distinguished road

      0  

    Default


    Works like a charm!

    This should be in docs, thank you very much!

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