How to disable tree collapse / expand


i got an already expanded tree and dont want the user to collapse or expand anything.
I looked on VAADIN Tree for something like Tree.setCollapsable(boolean) or a VetoableCollapseListener with boolean nodeCollapse(CollapseEvent) but i find nothing appropriate.

Any suggestions?

Have you tried calling

IIRC it’s not possible to disable expanding and collapsing. Setting readOnly doesn’t affect clicking the nodes and the node styles are applied on client side, when a click occurs. The changes are then sent to server side so even if you extend Tree you still can’t get rid of the collapsing. So as far as I know, only way is to modify the VTree to achieve this.

Well, setChildrenAllowed(itemId, boolean) does mark the item as a leaf, and disables the triangle, but I’m not sure if you can then add items under that leaf, or if that then throws an exception.

it is possible to setChildrenAllowed(foo, false) on all items
the tree has been build. the problem is that only the root nodes gets rendered after that, so this is no option for me :frowning:
i should file a feature request.

i created a new ticket

As a workaround you can also remove the collapse triangle via css or sass:

    background: inherit
    margin-left: 0px

This disables also the functionality to collapse items of the tree. (Tested with chrome, firefox and IE9.)