1. Domino UI
  2. Data table
  3. Tree eager
Top Full span Columns Docs

Tree - Eager

The TreeGridPlugin is a DataTable plugin that allows you to create hierarchical tables with expandable/collapsible rows. It provides functionality to expand and collapse rows, making it easy to display tree-like data structures in your DataTable. This plugin adds a utility column to the DataTable for expand/collapse icons in each row.

Usage example:

 
 TreeGridPlugin  treeGridPlugin = new TreeGridPlugin< >();
 treeGridPlugin.expandAllRows(true);

 DataTable  dataTable = DataTable.create();
 dataTable.addPlugin(treeGridPlugin);
 
All rows in the DataTable can be expanded or collapsed at once using the expandAllRows and collapseAllRows methods. You can also expand or collapse individual rows using the expandRow and collapseRow methods.

Examples

Eager tree - Full span A tree with all root and leaf records are loaded and rendered eagerly, root nodes span full row.

Eager tree - Root columns A tree with all root and leaf records are loaded and rendered eagerly, root nodes show columns.

API Docs: TreeGridPlugin

Constructors

public void TreeGridPlugin()
Constructs a new TreeGridPlugin with default configuration.

Public methods

public void init(DataTable<T> dataTable)
Initializes the TreeGridPlugin with the given DataTable. This method is called by the DataTable when the plugin is added. It sets up the necessary configuration and applies the TreeStateMeta to keep track of the tree state.

dataTable

The DataTable to which this plugin is being added.

public boolean requiresUtilityColumn()
Indicates whether this plugin requires a utility column in the DataTable. The utility column is used to display expand/collapse icons for tree rows.

Returns:

true if a utility column is required, false otherwise.

public void expandRow(TableRow<T> row, boolean recursive)
Expands a specific row in the DataTable.

row

The TableRow to expand.

recursive

Whether to recursively expand child rows.

public void onRowAdded(DataTable<T> dataTable, TableRow<T> tableRow)
Handles the event when a new row is added to the DataTable. If the TreeGridPlugin is not configured as lazy, it adds the children of the row to the table. If the added row was previously expanded, it ensures that the child rows are visible as well.

dataTable

The DataTable to which the row is added.

tableRow

The TableRow that was added.

public void onAllRowsAdded(DataTable<T> dataTable)
Handles the event when all rows are added to the DataTable. This method is called after all rows have been added.

dataTable

The DataTable to which rows are added.

public void expandRow(TableRow<T> row)
Expands a specific row in the DataTable with recursive expansion of child rows.

row

The TableRow to expand.

public void expandAllRows(boolean recursive)
Expands all rows in the DataTable. If "recursive" is set to true, child rows will also be expanded.

recursive

If true, child rows will also be expanded; otherwise, only the parent rows are expanded.

public void collapseRow(TableRow<T> row)
Collapses a specific row in the DataTable, hiding its child rows if any.

row

The TableRow to collapse.

public void collapseAllRows()
Collapses all rows in the DataTable, hiding child rows if any.
public Optional<List<HTMLElement>> getUtilityElements(DataTable<T> dataTable, RowCell<T> rowCell)
Generates utility elements to be displayed in a cell of the DataTable.

dataTable

The DataTable instance.

rowCell

Information about the cell.



Returns:

A list of utility elements to be displayed in the cell.

public void onHeaderAdded(DataTable<T> dataTable, ColumnConfig<T> column)
Handles the event when a header is added to the DataTable.

dataTable

The DataTable instance.

column

The ColumnConfig that was added as a header.

public void onBeforeAddRow(DataTable<T> dataTable, TableRow<T> tableRow)
Handles the event before adding a row to the DataTable.

dataTable

The DataTable instance.

tableRow

The TableRow to be added.

public void handleEvent(DominoEvent event)
Handles table-related events such as sorting, searching, data updates, and pagination. Updates the header icon and resets the expanded count if necessary.

event

The table event to handle.

public TreeGridPlugin<T> setConfig(TreePluginConfig<T> config)
Sets the configuration for the TreeGridPlugin.

config

The configuration to set.



Returns:

The TreeGridPlugin instance.

public TreePluginConfig<T> getConfig()
Retrieves the current configuration of the TreeGridPlugin.

Returns:

The current TreePluginConfig instance.

API Docs: TreePluginConfig

Constructors

public void TreePluginConfig()
Constructs a new TreePluginConfig with default settings.

Public methods

public boolean isLazy()
Checks if lazy loading of child rows is enabled.

Returns:

true if lazy loading is enabled; otherwise, false .

public TreePluginConfig<T> setLazy(boolean lazy)
Sets whether lazy loading of child rows should be enabled.

lazy

true to enable lazy loading; false to disable it.



Returns:

The TreePluginConfig instance.

public ParentRowCellsSupplier<T> getParentRowCellsSupplier()
Retrieves the supplier for parent row cells.

Returns:

The supplier for parent row cells.

public TreePluginConfig<T> setParentRowCellsSupplier(ParentRowCellsSupplier<T> parentRowCellsSupplier)
Sets the supplier for parent row cells.

parentRowCellsSupplier

The supplier for parent row cells.



Returns:

The TreePluginConfig instance.

public Supplier<ToggleIcon<?, ?>> getExpandToggleIconSupplier()
Retrieves the supplier for the expand/collapse toggle icon.

Returns:

The supplier for the expand/collapse toggle icon.

public TreePluginConfig<T> setExpandToggleIconSupplier(Supplier<ToggleIcon<?, ?>> expandIconSupplier)
Sets the supplier for the expand/collapse toggle icon.

expandIconSupplier

The supplier for the expand/collapse toggle icon.



Returns:

The TreePluginConfig instance.

public Supplier<Icon<?>> getLeafIconSupplier()
Retrieves the supplier for the leaf icon.

Returns:

The supplier for the leaf icon.

public TreePluginConfig<T> setLeafIconSupplier(Supplier<Icon<?>> leafIconSupplier)
Sets the supplier for the leaf icon.

leafIconSupplier

The supplier for the leaf icon.



Returns:

The TreePluginConfig instance.

public Function<TableRow<T>, Node> getIndentColumnElementSupplier()
Retrieves the supplier for the indent column element.

Returns:

The supplier for the indent column element.

public TreePluginConfig<T> setIndentColumnElementSupplier(Function<TableRow<T>, Node> indentColumnElementSupplier)
Sets the supplier for the indent column element.

indentColumnElementSupplier

The supplier for the indent column element.



Returns:

The TreePluginConfig instance.

public int getIndent()
Retrieves the indentation value for tree grid rows.

Returns:

The indentation value.

public TreePluginConfig<T> setIndent(int indent)
Sets the indentation value for tree grid rows.

indent

The indentation value.



Returns:

The TreePluginConfig instance.

We are a group of passionate people who love what we do

Donate & Support Us