1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Answers
    5
    Vote Rating
    1
    markevans is on a distinguished road

      0  

    Default Answered: Unable to add model instance to localstorage store (2.0.1.1)

    Answered: Unable to add model instance to localstorage store (2.0.1.1)


    Really frustrated with this one. As indicated in the title, I find myself unable to "add" data to a localstorage store. My previous app created under a previous version of ST seems to work, but not the new one I downloaded (2.0.1.1).

    I've set up my app to add a record each time the main view initializes. When I refresh the app, I still only have one data element with a fresh id - none of the previous ones stick. Am I doing something wrong?

    Model:
    Code:
    Ext.define('Tally.model.Instance', {
        extend: 'Ext.data.Model',
    
    
        requires: [ 'Ext.data.identifier.Uuid',
                     'Ext.data.proxy.LocalStorage'],
    
    
        config: {
            identifier: 'uuid',
            fields:     [
                        'instanceid',
                        'firstcontact',
                        'lastcontact',
                        'sessionid',
                        'sessionexpirationdate',
                        'rememberlogin',
                        'rememberloginuserid',
                        'pwlength',
                        'createddate'
                        ],
    
    
                        proxy: {
                            type: 'localstorage',
                            id: 'instances'
                        }
        }
    });
    Store:
    Code:
    Ext.define('Tally.store.Instances', {
        extend: 'Ext.data.Store',
        
        config: {
            model: 'Tally.model.Instance',
            autoLoad: false,
            storeId: 'instanceStore'
        }
    });
    Controller code:


    Code:
                var newTest = Ext.create('Tally.model.Instance', 
                    {
                        instanceid: 999,
                        sessionid: 'quick brown fox',
                        createddate: new Date()
                    });
                Ext.getStore('instanceStore').add(newTest);
                Ext.getStore('instanceStore').sync();
                console.log(Ext.getStore('instanceStore').data);

  2. you set autoLoad:false,but i have not seen where you load your store.

  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


    you set autoLoad:false,but i have not seen where you load your store.
    I write English by translator.

  4. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Answers
    5
    Vote Rating
    1
    markevans is on a distinguished road

      0  

    Default


    Indeed. Thank you.

Thread Participants: 1

Tags for this Thread