Ext.data.Store的each()忽略了过滤后的记录

Sha*_*der 5 extjs extjs4.1 extjs-stores

我正在使用Ext.data.Store的each().但是,当过滤存储时,此方法仅循环遍历过滤的记录.即使在商店中应用过滤器,我们是否有任何其他方法或解决方法来遍历商店的所有记录.

  var attStore = Ext.getStore("myStore");
        var allRecords = attStore.snapshot || attStore.data;
        allRecords.each(function (record) {
            if (record.data.IsUpdated) {
                record.set('updatedByUser', true);
            }
            else {
                record.set('updatedByUser', false);
            }
             record.commit();
        });
Run Code Online (Sandbox Code Playgroud)

该行 var allRecords = attStore.snapshot || attStore.data;实际上按预期返回所有记录,但是当我尝试使用record.data.property = something更新该记录(或该记录中的一个属性)时,该记录没有得到更新.

谢谢

kul*_*rim 11

用这个

var allRecords = store.snapshot || store.data;
Run Code Online (Sandbox Code Playgroud)

并像这样循环

allRecords.each(function(record) {
    console.log(record);
});
Run Code Online (Sandbox Code Playgroud)

看到这个商店快照


Ant*_*yVO 5

在 Sencha Touch 2.3 上,我需要执行以下操作来绕过过滤器。

var allRecords = store.queryBy(function(){return true;});

allRecords.each(function(r){
    doStuff();
});
Run Code Online (Sandbox Code Playgroud)