how to flatten hierarhical container/remove hierarchy during filtering

I have the following use case:

  • I have a project hierarchy (currently displayed with a treetable but before this I used a simple tree for this purpose)
  • next to the hierarchy I have a quick search textfield
  • the user can choose an item from the hierarcy in 2 ways:
    - select an item directly from the tree
    - or type some text in the quick search and choose one item from the resulting simple (non hierarchical) list

my problem is that if I apply a filter on the the container of the TreeTable the resulting list is still hierarchycal (It is common that both the maching item and its parent(s) are both displayed)

How to flatten the resulting list ( to contain only the matching items in a simple list without parents or any hierarchy)
Or at least how to mark the matching items ( for example highlight the matching part in the matching items)

The treetable is populated by hand from a plain old jdbc query (no jpa/hibernate/or any kind of persistence is used)
First properties are added with TreeTables own addContainerProperty and then items are added with TreeTable’s addItem method while processing the jdbc resultset

And finaly I when when I apply filter to the hiearchy I get the container by calling TreeTable’s getContainerDataSource, and then add the filter to the resulting container

What is the recomended way/best solution for my use case ?

          - use 2 different containers/2 different UI components with the same set of items (a hierarchical with a TreeTable, and an IndexedContainer with a Table ) and show only one at the time (TreeTable in case of hierarchical select , and Table if quicksearch textfield is not empty (so ContainerFilter is added to the table only))
          - Any other idea/solution

Thanks for your attention/ideas/solution :slight_smile: