View Full Version : ListStore#replaceAll doesn't reflect on removed filters

13 Nov 2011, 6:37 AM
I think that the method com.sencha.gxt.data.shared.ListStore#replaceAll is missing "else" part like

if (isFiltered()) {
} else {

I caught it implementing simple filter grid. It remains empty forefer after removing store filter and reload data.

14 Nov 2011, 2:31 AM
My workaround for this:

new ListStore(props.id()) {
public void replaceAll(List newItems) {

Colin Alworth
14 Nov 2011, 8:07 AM
Can you post a code sample demonstrating the issue? I'm unable to confirm using this test case:

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> {
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());
StoreFilter<Data> f = new StoreFilter<TestListStore.Data>() {
public boolean select(Store<Data> store, Data parent, Data item) {
return item.name.startsWith("a");
assertEquals(1, store.size());

store.replaceAll(Arrays.asList(data("aeiou"), data("apple"), data("xyz")));
assertEquals(2, store.size());
assertEquals(3, store.size());

Do I have the order wrong in replacing items or removing the filter?

14 Nov 2011, 11:09 AM
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.

Colin Alworth
14 Nov 2011, 11:35 AM
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.

Colin Alworth
14 Nov 2011, 2:29 PM
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.