-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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"
collapsible="true">
<tree model="@bind(vm.treeModel)" height="100%"
multiple="true" checkmark="true"
selectedItems="@bind(vm.selectedItems)" style="overflow:auto">
<template name="model" var="node">
<treeitem>
<treerow>
<treecell image="@load(node.imageUrl)"
label="@load(node.name)" />
</treerow>
</treeitem>
</template>
</tree>
</west>...</borderlayout>
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;
}
Best,
Wouter
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.
Asked: 2013-02-21 14:35:18 +0800
Seen: 77 times
Last updated: Mar 12 '13
Loading list of images Stored in the eclipse workspace
How many times get method called when i use modelView?
Using databinding in menupopup
ZK Clustering, Session Replication Question [closed]
Problem binding values to a composite component
How can i load a constant in .zul
set selectedItem of list in viewmodel - cleaner way? [closed]
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