PDA

View Full Version : [CLOSED] Filtering the bound store does not update the Ext.dataview.List



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);
}
}
});

kyr0
20 Oct 2011, 2:41 PM
In my examples it only updates the List if you call clearFilter() on the store first and
then add the filter manually by filter() call. Afterwards call refresh() on the list cmp reference.

Jamie Avins
31 Oct 2011, 10:38 AM
Known issue we will address in a forthcoming release.

stirucherai
28 Nov 2011, 2:35 AM
Dear,

While loading the store and refresh the list works, there is still one more issue. The previous selected index item is still shown as selected. For e.g. when we tap index item 5 from list of 10 and execute a filter to reduce the 10 to 8, after refresh the index element 5 (what ever it may ) is still shown selected.

ITEM1 ITEM1
ITEM2 ITEM3
ITEM3 ITEM4
ITEM4 ITEM6
ITEM5 <--Selected ITEM7 <--- SHOWN as Selected/highlighted
ITEM6 ITEM8
ITEM7 ITEM9
ITEM8 ITEM10
ITEM9
ITEM10


Thanks and Regards
Sarang