I've created a Context menu with a tree structure (added Menu items, then added Checkboxes within those menu items as sub-menu items). This works just fine in terms of adding/removing items manually. However, when it comes to programmatically resetting items there is a conflict in terms of a general Component vs. specific component (in this case, a Checkbox).
Component comp = contextMenu.getItems().get(x).getSubMenu().getItems().get(y);
if (comp instanceof Checkbox) {
((Checkbox) comp).setValue(false);
}
Note that comp is not in fact an instance of Checkbox; rather it is returning as com.vaadin.flow.component.contextmenu.MenuItem and that item cannot be cast to a Checkbox. So the question is, how would I uncheck a given Checkbox?
Aucun commentaire:
Enregistrer un commentaire