Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Searching all columns
Is there any way to filter all rows in a table by the contents of the row, such that the filter looks if any of the properties in an item contains some string "foo"?
I looked at the source code for IndexedContainer, and it seems to me that if I create new Filters for each property with the same search string ("foo"), it'll discard every item. This due to the fact that no items contain "foo" in every property.
See IndexedContainer.passesFilters(Item) for more information.
So, is there a way for me to filter by the string "foo" in any of the available properties?
I handled this problem by creating an extra hidden property that contains all the searchable strings of the other properties. Then I just filter using the hidden property.
First gotta state that I'm not that big fun of "Container.Filterable" interface. It is way too simple for lots of use cases and it is still sometimes hard to implement. For some of the most simplest cases it works quite nice. We'd definitely need a more versatile interface to abstract filtering/searches. Something inspired by Criteria in Hibernate might be a good option.
So the answer is pretty much "no" with the current IndexedContainer. An option is to create a totally new container for your purpose or extend indexed container so that multiple filter are treated as "OR" filters instead of "AND".
Please share your experiences so we can later come up with a decent solution that works in real life and can be included in the framework.
Quite a straightforward workaround that probably works fine for the case that Jonatan has (as he is already using IndexedContainer). Good work, thanks!
The (very custom) component I worked with didn't support hiding of properties so I didn't think of dysii's approach before. I added hiding of columns and now it works nicely :)