In a Vaadin tree component I want to be able to in real time add and remove styling on specific items using its itemId.
I’ve looked through the tree component and searched for similar questions, but In haven’t found anything. Does anyone have an idea of how to achieve this?
EDIT
I found a solution to the question some time ago but Nils reminded me with his answer that I never updated. This was my solution.
customerTree.setItemStyleGenerator(new Tree.ItemStyleGenerator() {
@Override
public String getStyle(Object itemId) {
Item item = customerTree.getItem(itemId);
String itemName =
item.getItemProperty("name").getValue().toString().toLowerCase();
return itemName.equals(filter) ? "bold" : "clear";
}
});
You can do this with a Tree.ItemStyleGenerator: