As far as I can see, the
parent
item in a TreeGrid does not change when a
chlid
is selected.
I want to visibly change the appearance of the parent so the user is aware that there is a current chlid selection. A lot of Tree compnents in various frameworks support this state. (usually in the form of a partial checkbox selection)
I’ve attemmpted to use StyleGenerator, however this only works on the item that triggered the event (click/select), and as far as I know there is no way to progamatically change the style of a given row in the TreeGrid.
So the code below only gets called on the child item being clicked, and does not re-evaluate all rows.
portfolioTree.setStyleGenerator(item -> {
List<PortfolioTreeItem> children = portfolioTree.getTreeData().getChildren(item);
if(!children.isEmpty()) {
Set<PortfolioTreeItem> selectedItems = portfolioTree.getSelectedItems();
for(PortfolioTreeItem c : children) {
if(selectedItems.contains(c)) {
return "child-selected";
}
}
return null;
}else {
return null;
}
});
Has anyone been able change the style of an arbitrary item in the Grid or have a way for me to style the parent of a selected child? - I might just have to add some jquery to handle this based on child set css…