Thank you for reporting this bug. We will make it our priority to review this report.
-
Sencha User
ListStore#replaceAll doesn't reflect on removed filters
I think that the method com.sencha.gxt.data.shared.ListStore#replaceAll is missing "else" part like
Code:
if (isFiltered()) {
...
} else {
visibleItems.addAll(newItems);
}
I caught it implementing simple filter grid. It remains empty forefer after removing store filter and reload data.
-
Sencha User
My workaround for this:
Code:
new ListStore(props.id()) {
@Override
public void replaceAll(List newItems) {
super.replaceAll(newItems);
applyFilters();
}
};
-
Can you post a code sample demonstrating the issue? I'm unable to confirm using this test case:
Code:
private static class Data {
private static int nextId = 0;
public final String id = String.valueOf(nextId++);
public String name;
public int number;
}
private class DataKeyProvider implements ModelKeyProvider<Data> {
@Override
public String getKey(Data item) {
return item.id;
}
}
private Data data(String name) {
Data m = new Data();
m.name = name;
return m;
}
public void testReplaceAllFiltered() {
ListStore<Data> store = new ListStore<Data>(new DataKeyProvider());
store.add(data("abc"));
store.add(data("def"));
StoreFilter<Data> f = new StoreFilter<TestListStore.Data>() {
@Override
public boolean select(Store<Data> store, Data parent, Data item) {
return item.name.startsWith("a");
}
};
store.addFilter(f);
store.setEnableFilters(true);
assertEquals(1, store.size());
store.replaceAll(Arrays.asList(data("aeiou"), data("apple"), data("xyz")));
assertEquals(2, store.size());
store.removeFilter(f);
assertEquals(3, store.size());
}
Do I have the order wrong in replacing items or removing the filter?
-
Sencha User
Try to bind a StoreFilterField with a Grid and
1. Load store data
2. Type filter query
3. Reload the store with another data set
4. Press backspace until StoreFilterField is empty
5. Reload the store with another data set
I came to the situation where after calling store.replaceAll(newData) I see in the store filters.size() == 0 and allItems.size() == newData.size() and visibleItems.size() == 0. The grid remains empty forever.
-
Thanks, I'll get back to you when I have a functioning test case that can reproduce this. If you can build a working test case/entrypoint that demonstrates this, we'll have a fix that much more quickly.
-
Okay, got it - there are almost certainly more cases where this is broken, possibly ListStore.addAll, and probably TreeStore has more.
SVN now has a set of tests, and fixes for several cases in ListStore where this crops up.