Trees MVVM Multiselect

asked 2013-02-21 14:35:18 +0800

wnederhof gravatar image wnederhof
33 2

Dear all,

I have the following code for creating a tree of files.

<borderlayout apply="org.zkoss.bind.BindComposer"
    viewModel="@id('vm') @init('jcloudide.vm.FileBrowserVM')">
    <west width="300px" title="File browser" splittable="true"
        <tree model="@bind(vm.treeModel)" height="100%"
            multiple="true" checkmark="true"
            selectedItems="@bind(vm.selectedItems)" style="overflow:auto">
            <template name="model" var="node">
                        <treecell image="@load(node.imageUrl)"
                            label="@load(node.name)" />

This is working fine, to the extent that it displays the correct tree. However, I want the user to be able to select multiple items using checkboxes, which I try using the selectedItems argument and setting both checkmark and multiple to true. However, this still shows me radio buttons instead of checkboxes. What am I doing wrong here?

The code for handling the selected items is as following in the MVVM:

    public Set<Treeitem> selectedItems = new HashSet<Treeitem>();

public Set<Treeitem> getSelectedItems() {
    return selectedItems;

public void setSelectedItems(Set<Treeitem> selectedItems) {
    this.selectedItems = selectedItems;



delete flag offensive retag edit


Wow, thanks a lot guys! I saw this message just yet, but this saved my project!

wnederhof ( 2013-03-12 23:33:46 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-02-25 03:02:44 +0800

dennis gravatar image dennis
3669 1 6

If you are using TreeModel, your model has to implement Selectable and return true in isMutiple(). And if you are using DefaultTreeModel, which implements TreeModel&Selectable already, you can call treeModel.setMultiple(true) to enable it.

link publish delete flag offensive edit

answered 2013-02-23 14:04:12 +0800

nsharma gravatar image nsharma flag of India
917 1 11

Your multiple ="true" is not working ,

use treeModel.setMultiple(true) in

public Tree getTreeModel(){ treeModel.setMultiple(true); return treeModel; }

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2013-02-21 14:35:18 +0800

Seen: 77 times

Last updated: Mar 12 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More