-
13 Nov 2011 6:37 AM #1
ListStore#replaceAll doesn't reflect on removed filters
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
I caught it implementing simple filter grid. It remains empty forefer after removing store filter and reload data.Code:if (isFiltered()) { ... } else { visibleItems.addAll(newItems); }
-
14 Nov 2011 2:31 AM #2
My workaround for this:
Code:new ListStore(props.id()) { @Override public void replaceAll(List newItems) { super.replaceAll(newItems); applyFilters(); } };
-
14 Nov 2011 8:07 AM #3
Can you post a code sample demonstrating the issue? I'm unable to confirm using this test case:
Do I have the order wrong in replacing items or removing the filter?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()); }
-
14 Nov 2011 11:09 AM #4
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.
-
14 Nov 2011 11:35 AM #5
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.
-
14 Nov 2011 2:29 PM #6
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.
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote