Results 1 to 5 of 5

Thread: Sencha Touch Store is not adding records, localstorage

  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    4

    Default Sencha Touch Store is not adding records, localstorage

    I wonder whats problem with localstorage that I can't save records.

    Code:
    Ext.application({
        models: [
            'Feed'
        ],
        stores: [
            'Feeds'
        ],
        views: [
            'MyList'
        ],
        controllers: [
            'MyController'
        ],
        name: 'MyApp',
    
    
        launch: function() {
            var st=Ext.getStore('Feeds');
    
    
            st.add([{pkid:2,name:'sata', age:38}]);
            st.sync();
            Ext.create('MyApp.view.MyList', {fullscreen: true});
        }
    
    
    });
    Ext.define('MyApp.store.Feeds', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'MyApp.model.Feed'
        ],
    
    
        config: {
            autoLoad: true,
            autoSync: true,
            model: 'MyApp.model.Feed',
            storeId: 'Feeds',
            proxy: {
                type: 'localstorage',
                id: 'Feeds'
            }
        }
    });
    
    Ext.define('MyApp.model.Feed', {
        extend: 'Ext.data.Model',
        alias: 'model.feed',
    
    
        config: {
            idProperty: 'pkid',
            fields: [
                {
                    name: 'pkid'
                },
                {
                    name: 'name'
                },
                {
                    name: 'age'
                }
            ]
        }
    });
    Attached Files Attached Files

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    4

    Default

    I found it , just delete the idProperty of the model (reseted to default idProperty: 'pkid')and loading the store at app launch. This is a bug with sencha touch 2.

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    Atlanta, Georgia
    Posts
    40

    Default Confused

    You overwrote the idProperty in the model before adding to the store?

  4. #4

    Default same problem

    I met the same problem, sencha please fix it

  5. #5
    Sencha User
    Join Date
    Jan 2012
    Location
    Atlanta, Georgia
    Posts
    40

    Default

    FWIW, my "solution" was to create a callback handler for the store's load() and call the model's setDirty() before inserting it into the store.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •