Class 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 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().

A screenshot of the treetable:

An example WTreeTable (default)

An example WTreeTable (polished)

See Also:
WTreeTableNode, WTreeView
  • Constructor Details

  • Method Details

    • 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.

    • render

      protected void render​(java.util.EnumSet<RenderFlag> flags)
      Description copied from class: WWidget
      Renders the widget.

      This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

      The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

      Overrides:
      render in class WCompositeWidget