azamat
azamat

Reputation: 13

Vaadin tree onclick expand

I am new to Vaadin and I want to know how can I expand tree node on click? More precisely I want the tree to expand when I click on parent node not expand button.

Upvotes: 0

Views: 4923

Answers (4)

K.Cho
K.Cho

Reputation: 1

tree.addItemClickListener(new ItemClickListener() {
    @Override
    public void itemClick(ItemClickEvent event) {
        menu.expandItem(event.getItemId());
    }
});

this works to me

Upvotes: 0

Mischa van Rijswijk
Mischa van Rijswijk

Reputation: 1

This working for me:

@Override
        public void itemClick(ItemClickEvent itemClickEvent) {
            final String column = itemClickEvent.getPropertyId().toString();
            final String item = (String) itemClickEvent.getItemId();
            if (column.equals(something)) {
                Boolean collapsed = functieTree.isCollapsed(item);
                LOGGER.debug("COLLAPSED: " + collapsed);
                tableTree.setCollapsed(item, !collapsed);
            }
        }

Upvotes: 0

Fariba
Fariba

Reputation: 723

For example if you want to expand all nodes in vaadin.ui.Tree:

// --- Expand all nodes
for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {
    tree.expandItemsRecursively(it.next());
}

Upvotes: 1

Balint Bako
Balint Bako

Reputation: 2560

It is quite easy to create a tree in Vaadin: https://vaadin.com/book/vaadin7/-/page/components.tree.html

Upvotes: 2

Related Questions