Package org.zkoss.zul

Class Tree

All Implemented Interfaces:
Serializable, Cloneable, Component, Scope, ComponentCtrl, Paginated

public class Tree extends MeshElement
A container which can be used to hold a tabular or hierarchical set of rows of elements.

Event:

  1. SelectEvent is sent when user changes the selection.
  2. onAfterRender is sent when the model's data has been rendered.(since 5.0.4)

Default getZclass(): z-tree. (since 3.5.0)

Custom Attributes:

org.zkoss.zul.tree.rightSelect
Specifies whether the selection shall be toggled when user right clicks on item, if the checkmark (isCheckmark()) is enabled.
Notice that you could specify this attribute in any of its ancestor's attributes. It will be inherited.
org.zkoss.zul.tree.autoSort
.(since 5.0.7)
Specifies whether to sort the model when the following cases:
  1. setModel(org.zkoss.zul.TreeModel<?>) is called and Treecol.setSortDirection(java.lang.String) is set.
  2. Treecol.setSortDirection(java.lang.String) is called.
  3. Model receives TreeDataEvent and Treecol.setSortDirection(java.lang.String) is set.
If you want to ignore sort when receiving TreeDataEvent, you can specifies the value as "ignore.change".
Notice that you could specify this attribute in any of its ancestor's attributes. It will be inherited.

[Since 6.0.0]

To retrieve what are selected in Tree with a TreeSelectableModel, you shall use TreeSelectableModel.isPathSelected(int[]) to check whether the current path is selected in TreeSelectableModel rather than using getSelectedItems(). That is, you shall operate on the item of the TreeSelectableModel rather than on the Treeitem of the Tree if you use the TreeSelectableModel and TreeModel.


 TreeSelectableModel selModel = ((TreeSelectableModel)getModel());
 int[][] paths = selModel.getSelectionPaths();
 List<E> selected = new ArrayList<E>();
 AbstractTreeModel model = (AbstractTreeModel) selModel;
 for (int i = 0; i < paths.length; i++) {
 		selected.add(model.getChild(paths[i]));
 }
 

[Since 6.0.0]

If the TreeModel in Tree implements a TreeSelectableModel, the multiple selections status is applied from the method of TreeSelectableModel.isMultiple()


 DefaultTreeModel selModel = new DefaultTreeModel(treeNode);
 selModel.setMultiple(true);
 tree.setModel(selModel);
 

[Since 6.0.0]

To retrieve what are opened nodes in Tree with a TreeOpenableModel, you shall use TreeOpenableModel.isPathOpened(int[]) to check whether the current path is opened in TreeOpenableModel rather than using Treeitem.isOpen(). That is, you shall operate on the item of the TreeOpenableModel rather than on the Treeitem of the Tree if you use the TreeOpenableModel and TreeModel.


 TreeOpenableModel openModel = ((TreeOpenableModel)getModel());
 int[][] paths = openModel.getOpenPaths();
 List<E> opened = new ArrayList<E>();
 AbstractTreeModel model = (AbstractTreeModel) openModel;
 for (int i = 0; i < paths.length; i++) {
 		opened.add(model.getChild(paths[i]));
 }
 
org.zkoss.zul.tree.selectOnHighlight.disabled
.(since 7.0.4)
Sets whether to disable select functionality when highlighting text content with mouse dragging or not.

[Since 7.0.0] (EE version only)
org.zkoss.zul.tree.initRodSize
.
Specifies the number of items rendered when the Tree first render.
org.zkoss.zul.tree.maxRodPageSize
.
Specifies how many pages (of treeitems) to keep rendered in memory (on the server side) when navigating the tree using pagination. (Paging mold only)
org.zkoss.zul.tree.preloadSize
.
Specifies the number of items to preload when receiving the rendering request from the client.

It is used only if live data (setModel(TreeModel) and not paging (getPagingChild()).

Author:
tomyeh
See Also: