eu.webtoolkit.jwt
Class WTreeTable

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WCompositeWidget
              extended by eu.webtoolkit.jwt.WTreeTable

public class WTreeTable
extends WCompositeWidget

A table with a navigatable tree in the first column.

A WTreeTable implements a tree table, where additional data associated is associated with tree items, which are organized in columns.

Unlike the MVC-based WTreeView widget, the tree renders a widget hierarchy, rather than a hierarhical standard model. This provides extra flexibility (as any widget can be used as contents), at the cost of server-side, client-side and bandwidth resources (especially for large tree tables).

The actual data is organized and provided by WTreeTableNode widgets.

To use the tree table, you need first to call addColumn() to specify the additional data columns. Next, you need to set the tree root using setTreeRoot() and bind additional information (text or other widgets) in each node using WTreeTableNode#setColumnWidget(). Thus, you cannot change the number of columns once the tree root has been set.

The table cannot be given a height using CSS style rules, instead you must use layout managers, or use WCompositeWidget#resize().

CSS

The treetable is styled by the current CSS theme. The look can be overridden using the Wt-treetable CSS class. The style selectors that affect the rendering of the tree are indicated in the documentation for WTree (for selection) and WTreeNode (for decoration). In addition, the following selector may be used to to style the header:

 .Wt-treetable .Wt-header : header
 

A screenshot of the treetable:

An example WTreeTable (default)

An example WTreeTable (default)

An example WTreeTable (polished)

An example WTreeTable (polished)

See Also:
WTreeTableNode, WTreeView

Constructor Summary
WTreeTable()
          Creates a new tree table.
WTreeTable(WContainerWidget parent)
          Creates a new tree table.
 
Method Summary
 void addColumn(java.lang.CharSequence header, WLength width)
          Adds an extra column.
 WLength columnWidth(int column)
          Returns the column width for the given column.
 int getColumnCount()
          Returns the number of columns in this table.
 WWidget getHeaderWidget()
          Returns the header widget.
 WTree getTree()
          Returns the tree that provides the data this table.
 WTreeTableNode getTreeRoot()
          Returns the tree root.
 WText header(int column)
          Returns the header for the given column.
 void setTree(WTree root, java.lang.CharSequence h)
          Sets the tree which provides the data for the tree table.
 void setTreeRoot(WTreeTableNode root, java.lang.CharSequence h)
          Sets the tree root.
 
Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, getAttributeValue, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isVisible, load, propagateSetEnabled, refresh, remove, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setTabIndex, setToolTip, setVerticalAlignment
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WTreeTable

public WTreeTable(WContainerWidget parent)
Creates a new tree table.

The getTreeRoot() is null. The table should first be properly dimensioned using addColumn() calls, and then data using setTreeRoot().


WTreeTable

public WTreeTable()
Creates a new tree table.

Calls this((WContainerWidget)null)

Method Detail

addColumn

public void addColumn(java.lang.CharSequence header,
                      WLength width)
Adds an extra column.

Add an extra column, specifying the column header and a column width. The extra columns are numbered from 1 as column 0 contains the tree itself. The header for column 0 (the tree itself) is specified in setTreeRoot(), and the width of column 0 takes the remaining available width.


getColumnCount

public int getColumnCount()
Returns the number of columns in this table.

Returns the number of columns in the table, including in the count column 0 (which contains the tree).

See Also:
addColumn(CharSequence header, WLength width)

setTreeRoot

public void setTreeRoot(WTreeTableNode root,
                        java.lang.CharSequence h)
Sets the tree root.

Sets the data for the tree table, and specify the header for the first column.

The initial root is null.

See Also:
getTreeRoot(), setTree(WTree root, CharSequence h)

getTreeRoot

public WTreeTableNode getTreeRoot()
Returns the tree root.


setTree

public void setTree(WTree root,
                    java.lang.CharSequence h)
Sets the tree which provides the data for the tree table.

See Also:
setTreeRoot(WTreeTableNode root, CharSequence h)

getTree

public WTree getTree()
Returns the tree that provides the data this table.

See Also:
setTree(WTree root, CharSequence h)

columnWidth

public WLength columnWidth(int column)
Returns the column width for the given column.

The width of the first column (with index 0), containing the tree, is implied by the width set for the table minus the width of all other columns.

See Also:
addColumn(CharSequence header, WLength width), setTreeRoot(WTreeTableNode root, CharSequence h)

header

public WText header(int column)
Returns the header for the given column.

See Also:
addColumn(CharSequence header, WLength width), setTreeRoot(WTreeTableNode root, CharSequence h)

getHeaderWidget

public WWidget getHeaderWidget()
Returns the header widget.

This is the widget that contains the column headers.