TreeComboBox
ComboBox like component with hierarchical data.
This is hierarchical ComboBox type single select component. It currently works with in-memory data providers, i.e. TreeDataProvider, it supports filtering, but not adding new items on the fly.
Features
- Filtering (can be disabled, when text field only shows the selected value)
- Select only leafs mode
- Clear button can be disabled
- Prefix icon
- Complete field API (error message, helper text, tooltip, required indicator)
Sponsored development
Major pieces of development of this add-on has been sponsored by customers of Vaadin. Read more about Expert on Demand at: Support and Pricing
Sample code
DepartmentData departmentData = new DepartmentData(); TreeComboBox<Department> treeComboBox = new TreeComboBox<>( Department::getName); treeComboBox.setItems(departmentData.getRootDepartments(), departmentData::getChildDepartments); treeComboBox.setLabel("Select one"); treeComboBox.setWidth("350px"); treeComboBox.addValueChangeListener(event -> { if (event.getValue() != null) { add(new Span(event.getValue().getName())); } else { Notification.show("No value"); } }); Checkbox leafsOnly = new Checkbox("Leafs Only"); leafsOnly.addValueChangeListener(e -> { treeComboBox.setSelectOnlyLeafs(e.getValue()); }); treeComboBox.setIcon(VaadinIcon.INFO.create()); treeComboBox.setClearButtonVisible(false); treeComboBox.setValue(departmentData .getChildDepartments(departmentData.getRootDepartments().get(0)) .get(0)); treeComboBox.setTooltipText("Tooltip"); treeComboBox.setHelperText("Helper"); treeComboBox.setPopupWidth("400px"); add(treeComboBox, leafsOnly);
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Version 2.0.0
- Updated for Vaadin 23 compatibility
- Released
- 2022-08-29
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 23
- Vaadin 24.4 in 3.3.0
- Vaadin 24.3 in 3.3.0
- Vaadin 24+ in 3.2.0
- Vaadin 14 in 1.1.0
- Browser
- Firefox
- Opera
- Safari
- Google Chrome
- iOS Browser
- Android Browser
- Microsoft Edge
TreeComboBox - Vaadin Add-on Directory
ComboBox like component with hierarchical data.TreeComboBox version 1.0.0
### Version 1.0.0
- First version, with baseline featureset
TreeComboBox version 1.1.0
Update license to Apache 2.0
TreeComboBox version 2.0.0
### Version 2.0.0
- Updated for Vaadin 23 compatibility
TreeComboBox version 3.0.0
### Version 3.0.0
- Vaadin 24 compatibility
TreeComboBox version 3.1.0
### Version 3.1.0
- Improve design by moving popup open button to prefix of the input field
TreeComboBox version 2.1.0
### Version 2.1.0
- Fix NPE issue with dataProvider being null
- Add option to select only the leaf nodes
TreeComboBox version 2.2.0
### Version 2.2.0
- Added setClearButtonVisible
- Added setIcon
- Implemented HasTooltip, HasValidation and HasHelper interfaces
TreeComboBox version 2.3.0
### Version 2.3.0
- Added setPopupWidth
TreeComboBox version 2.4.0
### Version 2.4.0
- Added setDisableFiltering API
TreeComboBox version 2.4.1
### Version 2.4.1
- Fixed issue with multiple TreeComboBoxes in the same view
TreeComboBox version 2.4.2
### Version 2.4.2:
- Fix issue with programmatic setValue not working if setSelectOnlyLeafs(true) was called first
TreeComboBox version 3.2.0
### Version 3.2.0
- Added setSelectOnlyLeafs, setClearButtonVisible, setIcon, setPopupWidth, setDisableFiltering
- Implemented HasTooltip, HasValidation and HasHelper
- Moved drop down open button to right
- Bug fixes
- Vaadin 24.2 or newer required
TreeComboBox version 3.3.0
### Version 3.3.0
- Updated to use new Tree version which improves keyboard navigation on popup. Space will toggle expand/collapse, Enter selects.