Reputation: 41
I am applying conditional highlighting to a TreeGrid, however, it does not apply the color to the row. I am using similar approach to Grid and it works flawlessly. Has anybody had similar issues with TreeGrid?
Code:
Trigger highlighting via Grid component button -
btnRed.addClickListener(clickEvent -> {
if (isContained(selectedItems.keySet(), systemAccessDTO)){
removeItemsRecursively(systemAccessDTO);
}else {
addItemsRecursively(systemAccessDTO);
}
updateStyles();
});
Updating style -
private void updateStyles() {
grid.setStyleGenerator(systemAccessDTO -> {
if (isContained(selectedItems.keySet(), systemAccessDTO)) {
return "red";
}
return null;
});
}
PS: Vaadin version 8.4.3
Thank you!
Upvotes: 1
Views: 397
Reputation: 41
I have found the problem. The Grid and TreeGrid classes in vaadin have different CSS classes. Posting this for anyone that has the same problem.
Styling the treegrid rows:
.v-treegrid-row.treegrid_custom_style .v-treegrid-cell {
background-color: #a8c9ff;
}
.v-treegrid-row-stripe.treegrid_custom_style .v-treegrid-cell {
background-color: #a8c9ff;
}
Upvotes: 3