yoh.suzuki
20 Oct 2011, 2:04 PM
I'm experiencing several issues.
1.) Filtering the Store does not notify the List that anything has changed. Workaround: fire the 'load' event to force the List to update.
myStore.filter({ filterFn: ... });
myStore.fireEvent('load'); // <-- workaround
2.) When you filter the Store, it properly trims down its 'data' property, but the List can display records that do not match the filter. Here's a quick override I did to fix this issue for now. My two changes to Ext.dataview.DataView are annotated in the comments below.
Ext.define('wut', {
override: 'Ext.dataview.DataView',
doRefresh: function(me) {
var store = me.getStore(),
records = store.getRange(),
items = me.getViewItems(),
recordsLn = records.length,
itemsLn = items.length,
deltaLn = recordsLn - itemsLn,
i, item;
if (recordsLn < 1) {
me.onStoreClear();
return;
}
if (deltaLn < 0) {
this.moveItemsToCache(itemsLn + deltaLn, itemsLn - 1);
//return; // <-- we still have to update the list items so do not return here
}
else if (deltaLn > 0) {
this.doCreateItems(store.getRange(itemsLn), itemsLn);
}
for (i = 0; i < recordsLn; i++) { // <-- use recordsLn instead of itemsLn
item = items[i];
me.updateListItem(records[i], item);
}
}
});
1.) Filtering the Store does not notify the List that anything has changed. Workaround: fire the 'load' event to force the List to update.
myStore.filter({ filterFn: ... });
myStore.fireEvent('load'); // <-- workaround
2.) When you filter the Store, it properly trims down its 'data' property, but the List can display records that do not match the filter. Here's a quick override I did to fix this issue for now. My two changes to Ext.dataview.DataView are annotated in the comments below.
Ext.define('wut', {
override: 'Ext.dataview.DataView',
doRefresh: function(me) {
var store = me.getStore(),
records = store.getRange(),
items = me.getViewItems(),
recordsLn = records.length,
itemsLn = items.length,
deltaLn = recordsLn - itemsLn,
i, item;
if (recordsLn < 1) {
me.onStoreClear();
return;
}
if (deltaLn < 0) {
this.moveItemsToCache(itemsLn + deltaLn, itemsLn - 1);
//return; // <-- we still have to update the list items so do not return here
}
else if (deltaLn > 0) {
this.doCreateItems(store.getRange(itemsLn), itemsLn);
}
for (i = 0; i < recordsLn; i++) { // <-- use recordsLn instead of itemsLn
item = items[i];
me.updateListItem(records[i], item);
}
}
});