Search code examples
gwtfilterfilteringstoregxt

GXT add filter to store


I'm having problems with a relatively simple piece of code.

I'm trying to set a filter for my store items (store associated with a GridView).

gridStore.addFilter(new StoreFilter<IncidentDto>() {
                    @Override
                    public boolean select(Store<IncidentDto> store, IncidentDto parent, IncidentDto item) {
                        if (item.getDescription().equals("WEEEE-TEST")) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                });

The problem is the store doesn't filter at all.

Thanks to anyone who will take the time to help me out with this.


Solution

  • Don't forget to enable the filters - this exists so that you can make several filter modifications without actually asking them to act:

    gridStore.setEnableFilters(true);
    

    Sorting doesn't have this as there isn't a concept of turning sorting 'off' - items are sorted to have a new order, then they stay that order. In contrast, filters can be turned back off to restore the items that are no longer visible.