Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    13
    Vote Rating
    0
    nomad is on a distinguished road

      0  

    Default 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
    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.

  2. #2
    Sencha User
    Join Date
    Sep 2009
    Posts
    13
    Vote Rating
    0
    nomad is on a distinguished road

      0  

    Default


    My workaround for this:
    Code:
    new ListStore(props.id()) {
            @Override
            public void replaceAll(List newItems) {
                super.replaceAll(newItems);
                applyFilters();
            }
        };

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,717
    Vote Rating
    89
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    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?

  4. #4
    Sencha User
    Join Date
    Sep 2009
    Posts
    13
    Vote Rating
    0
    nomad is on a distinguished road

      0  

    Default


    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.

  5. #5
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,717
    Vote Rating
    89
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    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.

  6. #6
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,717
    Vote Rating
    89
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    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.

Thread Participants: 1

Tags for this Thread