【问题标题】:Update value with Sencha Touch / Ext JS localstorage duplicated entries使用 Sencha Touch / Ext JS localstorage 重复条目更新值
【发布时间】:2012-01-06 20:52:11
【问题描述】:

我想更新本地存储中记录的值。目前它将添加一个具有相同 id 的新记录,重复。例如,如果函数更新将在包含所有 id 的行(此处为“test-proxy”)执行,那么它将再次附加相同的 id。

model.Test = Ext.regModel('model.Test', {
    idProperty: 'id',
fields : [ {
    name : 'id',
    type : 'integer'
}, {
    name : 'name',
    type : 'string'
}
]});


//Store
store = new Ext.data.Store({
model : 'model.Test',
sorters : 'title',
storeId : 'test',
 proxy: {
    type: 'localstorage',
    id  : 'test-proxy',
    idProperty: 'id'
}
});

updateName = function(id) {
    store.read();
    var item = store.getAt(id-1).data;

    //toggle
    item.name = "Update"
    store.add(item);
    store.sync();
    console.log(store.getAt(id-1));
}

【问题讨论】:

  • 好的,我遇到的问题更像是缓存或重新加载问题。因为如果我重新加载页面一切都很好。问题是旧的(未更新的)数据仍在 Ext.DataView 中。浏览器重新加载页面后,只会列出更新的项目。

标签: extjs sencha-touch local-storage store


【解决方案1】:

好的,我找到了解决该问题的方法。该问题与刷新 DataView 有关。

store.load();
listData.refresh(); // will refresh  Ext.DataView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-21
    • 1970-01-01
    • 1970-01-01
    • 2019-08-31
    • 1970-01-01
    • 1970-01-01
    • 2015-12-26
    • 1970-01-01
    相关资源
    最近更新 更多