0

所以我的问题是这个。我可以第一次从本地存储代理中删除记录。但是如果我再做一次,它会给我一个错误,商店中的所有东西都是未定义的,就像它不再存在一样。

 onTapRemoveKegelReminder: function(button) {
    console.log(button.getData());
    //Find and delete the button and the record
    var store = Ext.getStore('KegelReminders');
    store.load();
    store.filter('button_id', button.getData());
    var record = store.first();


    console.log(record);
    console.log(button.getData());
    console.log('Remove count'+ store.getCount());


    if (typeof record !== 'undefined'||record!=null ) {
        store.remove(record);
        store.sync();


        console.log('removed record correctly')
        this.trainingCount--;
        var rmButton = this.getKegelExercises().down('#container-' + button.getData());
        this.getKegelExercises().remove(rmButton);

    }

但是,如果我重新启动我的应用程序,然后再次删除它就可以正常工作。我似乎不能多次删除而不必重新启动应用程序。

4

1 回答 1

3

仅供参考,以防其他人发现这一点,从 Store 中删除记录只会将其从该 store 实例中删除,而不是从存储机制(例如,localstorage)中删除。如果你想这样做,你必须使用模型对象上的erase方法。

store.remove(record); // may not even be necessary
record.erase();
store.sync();
于 2013-02-07T20:14:58.807 回答