tree checkmark true and mutiple true

asked 2012-07-06 11:14:15 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2625 3 8


The problem in the below code is even though i set checkmark = true and multiple = true, but still shows like radio button only. i,e single selection.
I want to make as per the demo

Here is the code.

Zul File

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<div id="treeDiv" apply="mypack.TreeComposer">
  <label id="lbl" />
    <tree id="treeGrid" checkmark="true" multiple="true" width="550px" model="@{treeDiv$composer.treeModel}" treeitemRenderer="@{treeDiv$composer.treeRenderer}">
            <treecol width="200px" label="Path" />
            <treecol width="350px" label="Description" />


package mypack;

import java.util.ArrayList;
import java.util.List;

import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.DefaultTreeModel;
import org.zkoss.zul.DefaultTreeNode;
import org.zkoss.zul.Div;
import org.zkoss.zul.Label;
import org.zkoss.zul.Tree;
import org.zkoss.zul.Treecell;
import org.zkoss.zul.Treeitem;
import org.zkoss.zul.TreeitemRenderer;
import org.zkoss.zul.Treerow;
public class TreeComposer extends GenericForwardComposer<Div> {

  private Label lbl;
	public void doAfterCompose(Div comp) throws Exception {
	public void onInitModel$treeGrid() {
		lbl.setValue(lbl.getValue() + "onInitModel/");

	public void onInitRender$treeGrid() {
		lbl.setValue(lbl.getValue() + "onInitRender/");
	public DefaultTreeModel<FileInfo> getTreeModel() {
		return new DefaultTreeModel<FileInfo>(getFileInfoTreeData());
	public FileInfoRenderer getTreeRenderer() {
		return new FileInfoRenderer();
	private DefaultTreeNode<FileInfo> getFileInfoTreeData() {
		List<DefaultTreeNode<FileInfo>> inner3 = new ArrayList<DefaultTreeNode<FileInfo>>();
		inner3.add(new DefaultTreeNode<FileInfo>(new FileInfo("zcommon.jar", "ZK Common Library")));
		inner3.add(new DefaultTreeNode<FileInfo>(new FileInfo("zk.jar", "ZK Core Library")));
		List<DefaultTreeNode<FileInfo>> inner2 = new ArrayList<DefaultTreeNode<FileInfo>>();
		inner2.add(new DefaultTreeNode<FileInfo>(new FileInfo("/lib", "ZK Libraries"), inner3));
		inner2.add(new DefaultTreeNode<FileInfo>(new FileInfo("/src", "Source Code")));
		inner2.add(new DefaultTreeNode<FileInfo>(new FileInfo("/xsd", "XSD Files")));
		List<DefaultTreeNode<FileInfo>> inner1 = new ArrayList<DefaultTreeNode<FileInfo>>();
		inner1.add(new DefaultTreeNode<FileInfo>(new FileInfo("/doc", "Release and License Notes")));
		inner1.add(new DefaultTreeNode<FileInfo>(new FileInfo("/dist", "Distribution"), inner2));

		return new DefaultTreeNode<FileInfo>(null, inner1);
	public class FileInfoRenderer implements TreeitemRenderer<DefaultTreeNode<FileInfo>> {

		public void render(final Treeitem item, DefaultTreeNode<FileInfo> data, int index) throws Exception {
			final FileInfo fi = data.getData();
			//for update treeNode data
			Treerow tr = item.getTreerow();
			if(tr == null) {
				tr = new Treerow();
			} else {
			//render file path cell

			Treecell pathCell = new Treecell();
			//render file description cell
			Treecell descriptionCell = new Treecell();
	public class FileInfo {
		private String path;
		private String description;

		public FileInfo() {}
		public FileInfo(String path, String description) {
			this.path = path;
			this.description = description;

		public String getPath() {
			return path;

		public void setPath(String path) {
			this.path = path;

		public String getDescription() {
			return description;

		public void setDescription(String description) {
			this.description = description;

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2012-07-07 17:35:04 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2625 3 8

Please help

link publish delete flag offensive edit

answered 2012-07-23 16:28:13 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2625 3 8

Can someone please help me in this......................

link publish delete flag offensive edit

answered 2012-07-23 16:33:36 +0800

gekkio gravatar image gekkio flag of Finland
899 1

If you use DefaultTreeModel, you must set the multiple flag in the model, not in the tree component:

public DefaultTreeModel<FileInfo> getTreeModel() {
  DefaultTreeModel<FileInfo> model = new DefaultTreeModel<FileInfo>(getFileInfoTreeData());
  return model;

link publish delete flag offensive edit

answered 2012-07-23 17:14:02 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2625 3 8

Thanks a lot.............. Do you have some example for the same in mvvm

link publish delete flag offensive edit

answered 2019-08-20 21:47:55 +0800

kellycasma gravatar image kellycasma

Muchas Gracias!

link publish delete flag offensive edit
Your reply
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




Asked: 2012-07-06 11:14:15 +0800

Seen: 208 times

Last updated: Aug 20 '19

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