Tree grid

TreeGridControl

Show an org chart or any parent-child list as a table users can expand.

Overview

TreeGridControl is a Blazor tree grid: a table whose rows nest under parents, built from a flat list with an Id and a ParentId column. Use it, rather than a tree view, when each node carries columns, as in an org chart; TreatAsParent and LoadChildren fetch a branch only when users open it. Map the hierarchy with IdMapping and ParentIdMapping.

Examples

#4,009 airports, loaded as you open them

Open a continent, a country, then an airport: each level loads its children the first time it opens, and the line under the grid counts the rows loaded so far.

PlaceType or surfaceAirportsRunwaysLongest runway (ft)Elevation (ft)
−Europe56477715,092

6 of 9,513 rows loaded

#Org chart: who reports to whom

Search a name, title, office or division (try Lisbon or Guide) and press Enter: matches keep every manager above them, vacant posts stay, and the Name column is pinned.

NameTitleOfficePeople belowGradeContractSalaryRatingStartedAlso reports to
−Albus DoorChief Executive OfficerBoston1,0459Permanent$455,100
2011-08-28
Clover YarrowExecutive AssistantBoston3Permanent$62,300
2025-10-26

1,084 of 1,084 posts shown; 38 vacant, 25 on leave.

Documentation

TreeGridControl renders its own table: it is not a GridControl wrapper and forwards no parameter. It shares GridControl's best-fit engine (ColumnAutoFit), sort pipeline, exporter and toolbar item model, and takes its events as direct parameters rather than an EventsRef object. One row is selected at a time. The 97 parameters are grouped by purpose: 74 in the tables below, the 23 EventCallbacks under Events.

ParameterTypeDefaultDescription
DataSourceIEnumerable<TValue>?nullThe flat list of rows. The hierarchy is rebuilt when a different list instance is assigned, not when the same list is mutated; both examples build a new list and remount with @key. Keys must be non-null and unique and parent links acyclic, or an ArgumentException is thrown.
ChildContentRenderFragment?nullThe TreeGridColumn declarations. They render into a hidden element and register themselves with the control, which draws from that list.
IdMappingstring""Name of the public property that holds each row's key, read by reflection. Empty builds no rows; a name that is not a property throws.
ParentIdMappingstring""Name of the property that holds the parent's key. Null, or a key no row has, makes the row a root.
TreatAsParentFunc<TValue, bool>?nullMarks a row expandable although no child is in the list, until a LoadChildren call for it has completed. Without LoadChildren such a row only gains the icon and the Expanded / Collapsed events; the first example passes it for rows that already have children.
LoadChildrenFunc<TValue, CancellationToken, Task<IReadOnlyList<TValue>>>?nullLazy loading: called the first time a TreatAsParent row opens, with the row and a token canceled on dispose, and must return that row's direct children (parent key equal to its key, else ArgumentException). The children join the tree and stay until a new DataSource instance arrives; a failure raises LoadFailed.
TreeColumnIndexint0Index, in the declared column list, of the column that carries the indent, the expand icon and the folder icon. A hidden column there falls back to the same index among the visible columns.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.