1. #1
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    38
    Vote Rating
    2
    rklowe01 is on a distinguished road

      0  

    Default Store using localstorage proxy has undefined data at start-up

    Store using localstorage proxy has undefined data at start-up


    I'm trying to save data in local storage using a store and localstorage proxy. At start-up, the store has data in it (I call store.getCount() and can see that there are 12 records). However, when I get a record using store.getAt() and then print the contents to console, it says that the record is undefined. While the app is running, I can add data to the store and retreive/read the data while the app is running, however, if I reload the app, I get the same undefined error. Please see code below:

    Model:
    Code:
    Ext.define('GameDay.model.Depth', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {
                    name: 'field1'
                },
                {
                    name: 'field2'
                }
            ]
        }
    });
    Store:

    Code:
    Ext.define('GameDay.store.DepthStore', {    extend: 'Ext.data.Store',
        requires: [
            'GameDay.model.Depth'
        ],
    
    
        config: {
            autoLoad: true,
            autoSync: true,
            model: 'GameDay.model.Depth',
            storeId: 'DepthStore',
            syncRemovedRecords: true,
            proxy: {
                type: 'localstorage'
            }
        }
    });
    At start-up, the following code reads the store data and outputs to console:
    Code:
    var store = Ext.getStore('DepthStore');
    store.load(function(records, operation, success) {
        console.log('loaded records');
    }, this);
    store.sync();
    var numRecords = store.getCount();
    console.log('Num records = ', numRecords);
    var read = Ext.create('GameDay.model.Depth');
    read = store.getAt(0);
    console.log('Store Record 0, Field 2 = ', read.field2);
    The console output for above code is: (as you can see, there are 12 records, but data is undefined??)
    loaded records
    DefineDepthController.js:48Num records = 12
    DefineDepthController.js:52Store Record 0, Field 2 = undefined

    If I remove all data from the store using store.removeAll(), and then add 12 new records using store.add(), I can see the data on the console:
    Num records = 12
    DefineDepthController.js:145Store Record 0, Field 2 = Red

    If I then re-load the app (refresh the web browser), the store still contains the 12 records added previously, but the data is being displayed again as undefined:
    loaded records
    DefineDepthController.js:48Num records = 12
    DefineDepthController.js:52Store Record 0, Field 2 = undefined

    Please help - I don't know if I'm doing something wrong, or is this a bug.
    Last edited by aconran; 4 May 2012 at 8:53 PM. Reason: add code tags

  2. #2
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    38
    Vote Rating
    2
    rklowe01 is on a distinguished road

      0  

    Default


    Anyone?... please.... my trial is about to expire and getting this solved will affect my decision to purchase Architect...

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    350
    Vote Rating
    1
    bharatn is on a distinguished road

      0  

    Default


    Not able to reproduce what you have. Can you try with the attach project and see what you have different?
    on first run, you will see undefined from getAt. Add some records from the form and you will see the record in the console.
    Attached Files
    Bharat Nagwani
    Sencha Designer Development Team

  4. #4
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    38
    Vote Rating
    2
    rklowe01 is on a distinguished road

      0  

    Default


    Problem solved... rookie mistake... turned out I was getting and setting record data the wrong way.

    Wrong:
    var value = record.fieldname;
    record.fieldname = value;

    Correct:
    var value = record.get('fieldname');
    record.set('fieldname', value);

    Thanks for your help!!

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