Skip to main content
TeeGrid supports hierarchical data through expandable rows, enabling master-detail relationships and multi-level data nesting.

Overview

Hierarchical data in TeeGrid is implemented using:
  • Expander - A render that adds expand/collapse icons to rows
  • OnGetData - Event to provide data for expanded rows
  • OnNewDetail - Event called when a detail grid is created
  • TRowGroup - Each expansion level is a separate row group

Basic Master-Detail Setup

OnGetData Event

Provide data for the expanded row:

Array Data Master-Detail

AlwaysExpand Property

Control when expand icons appear:

CanExpand Event

Control which rows can be expanded:

OnNewDetail Event

Customize the detail grid when created:

Multi-Level Hierarchies

Create 3+ levels of nesting:

Database Master-Detail

Using FireDAC with master-detail queries:

Programmatic Expansion

Expand/collapse rows programmatically:

Toggle All Rows Example

Expander Icons

Customize the expand/collapse icons:

Detail Grid Formatting

Apply formatting to detail grids:

Detail Grid Selection

Handle selection in detail grids:

Children Property

Access expanded detail grids:

Remove All Detail Grids

Enable/Disable Master-Detail

Performance Tips

For large hierarchies:

Best Practices

  • Use AlwaysExpand := True for dynamic data where you don’t know row count in advance
  • Set OwnsData := True on returned data objects so they’re freed automatically
  • Use OnNewDetail to customize appearance of detail grids
  • Limit nesting levels (3-4 max) for usability
  • Apply distinct colors to each level for visual hierarchy
  • Use database queries with parameters for efficient master-detail
  • Consider pagination for large detail sets
  • Provide “Expand All” / “Collapse All” buttons for user convenience