Add-on Directory

← Back

TreeComboBox

ComboBox like component with hierarchical data.

Author

Contributors

Rating

Popularity

500+

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);

Compatibility

(Loading compatibility data...)

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 3.3.0

  • Updated to use new Tree version which improves keyboard navigation on popup. Space will toggle expand/collapse, Enter selects.
Released
2024-07-17
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 24.3
Vaadin 24.4
Vaadin 24+ in 3.2.0
Vaadin 23 in 2.4.2
Vaadin 14 in 1.1.0
Browser
Firefox
Opera
Safari
Google Chrome
iOS Browser
Android Browser
Microsoft Edge

Vaadin Add-on Directory

Find open-source widgets, add-ons, themes, and integrations for your Vaadin application. Vaadin Add-on Directory
The channel for finding, promoting, and distributing Vaadin add-ons.
Online