-
FEATURED COMPONENTS
First time here? Check out the FAQ!
am trying to get all the selected items inside a tree model with the following ZKscript:
Iterator it = tree.getSelectedItems().iterator();
while (it.hasNext()){
Treeitem treeitem = it.next();
alert("you select item - "+treeitem.getLabel());
}
but all it returns the first level of my tree knowing that my tree has three or four levels or childs how can i retrieve the label of those childs with zscript plz!!!
You can refer following demo example...
ViewModel for tree example
public class TreeSelectionVM {
private TreeModel<TreeNode<String>> itemTree;
private String pickedItem;
//omit getter and setter for brevity
}
And ZUL Page code
<window apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('org.zkoss.reference.developer.mvvm.collection.TreeSelectionVM')">
<tree id="tree" model="@bind(vm.itemTree) " width="600px"
selectedItem="@bind(vm.pickedItem)">
<treecols>
<treecol label="name" />
<treecol label="index" />
</treecols>
<template name="model" var="node" status="s">
<treeitem open="@bind(node.open)">
<treerow>
<treecell label="@bind(node.data)" />
<treecell label="@bind(s.index)" />
</treerow>
</treeitem>
</template>
</tree>
</window>
For more information you can refer ZK Official Document
For Single selection of item developer can use
selectedItem="@bind(vm.pickedItem
and for multiple item selection
selectedItems="@bind(vm.pickedItemSet)"
I think you did not checked link posted by me See there
Binding to Selected Item
Asked: 2013-02-04 15:10:40 +0800
Seen: 90 times
Last updated: Feb 05 '13