简体   繁体   中英

GXT Grid filtering a store

I understand that in GXT 3.0 grids are pulling their data from a store (in my case a list store). I am trying to implement a search function to help filter through some of the results in the grid dynamically. However, I am having trouble determining the best method to do this. I have considered doing this server side by modifying the source file..but ultimately I just want to toggle the displaying of a row if it doesn't contain a desired string. Any suggestions for how to best approach this?

You can try using store filter to toggle displaying row that contains the string you desired. Here is the example code:

ListStore<YourModelData> listStore = new ListStore<YourModelData>(yourPropertiesObject.key());
StoreFilter<YourModelData> sf = new StoreFilter<YourModelData>() {
    @Override
    public boolean select(Store<YourModelData> store, YourModelData parent,
            YourModelData item) {
        return item.contains("some-string");
    }
};
listStore.addFilter(sf);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM