Docs

Documentation versions (currently viewingVaadin 25 (prerelease))

Tree Grid

The Tree Grid component displays hierarchical tabular data grouped in expandable nodes.

Tree Grid is a component for displaying hierarchical tabular data grouped into expandable nodes.

Open in a
new tab
Source code
TreeGridBasic.java
Person.java
tree-grid-basic.tsx
tree-grid-basic.ts
Note
Tree Grid is an extension of the Grid component. Therefore, all of Grid’s features are available in Tree Grid. However, Tree Grid isn’t meant to be used as a navigation menu.

Tree Column

The tree column contains the toggles for expanding and collapsing nodes. Nodes are opened and closed by clicking a tree column’s cell. They can also be toggled programmatically.

Open in a
new tab
Source code
TreeGridColumn.java
Person.java
tree-grid-column.tsx
tree-grid-column.ts

Rich Content

Like Grid, Tree Grid supports rich content.

Open in a
new tab
Source code
TreeGridRichContent.java
Person.java
tree-grid-rich-content.tsx
tree-grid-rich-content.ts

Programmatic Scrolling

Tree Grid supports programmatic navigation to a specific item. This is particularly useful when dealing with large data sets. It saves users from having to scroll through potentially hundreds or thousands of rows.

Scrolling to an Item (Flow only)

To use this feature, you need to specify the item you want to view. The scroll position of the grid is adjusted to bring that item into view.

If the item has collapsed parents, they expand before scrolling to the item.

Open in a
new tab
Source code
TreeGridScrollToItem.java

TreeDataProvider supports this feature out of the box. For other data providers, you need to override and implement the following methods of HierarchicalDataProvider:

  • getParent(T item)

  • getItemIndex(T item, HierarchicalQuery query)

Scrolling to an Item by Path

You can also scroll to an item by providing its hierarchical path – an array of indexes where each index refers to a child of the item at the previous index. For example, to scroll to the second child-row (index 1) of the third root-level row (index 2), you would provide the path 2, 1.

Scrolling continues until it reaches the last index in the array or encounters a collapsed item.

Open in a
new tab
Source code
TreeGridScrollToIndex.java
tree-grid-scroll-to-index.tsx
tree-grid-scroll-to-index.ts
Component Usage Recommendation

Grid

Component for showing tabular data.

Grid Pro

Component for showing and editing tabular data.

CRUD

Component for creating, displaying, updating, and deleting tabular data.

9DEF736F-975A-469A-8625-A0A6E086BF50