Skip to main content

TreeGridElement

Playwright element wrapper for Vaadin Tree Grid, extending GridElement with tree-specific APIs for expanding/collapsing rows, querying hierarchy levels, and performing bulk operations by level.

Component Tag

vaadin-grid (same as Grid, with tree-specific features)

Inheritance

Extends GridElement - all Grid methods are available plus tree-specific methods.

Constructor

Locator
required
Playwright locator for the <vaadin-grid> element backed by a TreeGrid

Static Factory Methods

get

Get the first tree grid on the page or within a parent locator.
Page
Playwright page
Locator
Parent locator to search within

getById

Get a tree grid by its id attribute.
Page
Playwright page
String
Element id

Tree Row Query Methods

findTreeRow

Find the tree row at the given index, returning a TreeRowElement.
int
0-based row index
Returns a TreeRowElement that exposes tree-specific state and actions.

isRowExpanded

Whether the row at the given index is expanded.
int
0-based row index

isRowCollapsed

Whether the row is collapsed (has children but is not expanded).
int
0-based row index

isRowLeaf

Whether the row is a leaf node (has no children).
int
0-based row index

getRowLevel

Get the hierarchy level of the row (0-based; root items are level 0).
int
0-based row index

getExpandedRowCount

Get the number of currently visible expanded rows.

Expand/Collapse Methods

expandRow

Expand the row at the given index. Does nothing if already expanded or is a leaf.
int
0-based row index

collapseRow

Collapse the row at the given index. Does nothing if already collapsed or is a leaf.
int
0-based row index

toggleRow

Toggle the expand/collapse state. Does nothing if the row is a leaf.
int
0-based row index

Inner Class: TreeRowElement

Extends GridElement.RowElement with tree-specific state queries and actions.

Methods

  • Locator getTreeToggleLocator() - Get the tree toggle locator
  • boolean isExpanded() - Whether the row is expanded
  • boolean isLeaf() - Whether the row is a leaf
  • boolean isCollapsed() - Whether the row is collapsed
  • int getLevel() - Get the hierarchy level
  • void expand() - Expand the row
  • void collapse() - Collapse the row
  • void toggle() - Toggle expand/collapse state

Usage Examples

Basic Tree Operations

Expand and Collapse Rows

Work with TreeRowElement

Check Hierarchy Levels

Count Expanded Rows

Toggle Row State

Check Leaf Nodes

Work with Multi-select