Hierarchical search on TreeDataProvider


I’m using a TreeDataProvider to populate a tree with data from Amazon S3,

I’m filtering in this way by treeDataProvider.setFilter, it makes a filter only on the first hierarchical level.

Is there a way to do a search in all the levels?



The method works as documented (https://vaadin.com/docs/v8/framework/datamodel/datamodel-hierarchical.html):

For TreeDataProvider, both the sorting and filtering API is the same as in ListDataProvider. Sorting and filtering are applied separately for each hierarchy level, meaning e.g. that for a node that has not passed the filter there are no children shown.

To get around this, you can make your own filtering method that takes into account the children’s contents. There’s an example implementation in this GitHub issue: https://github.com/vaadin/framework/issues/9933#issuecomment-466457099

Hi Katri,

thanks for the suggestion.

Hi Katri,

after applying you suggestion, the filter is perfect.

I have another strange situation:

After i apply the filter, then there are nodes that has non children.

When i click to open a node that has no children, the tree freezes.

Some hints ?

Thanks a lot.


I think I found the problem: https://github.com/vaadin/framework/issues/10104. There are some workarounds presented in that GitHub ticket as well as in this other ticket https://github.com/vaadin/framework/issues/8492, although nothing seems to work for all. Hope this helps nonetheless!