TreeList
Since 0.1.0-alpha.24Displays rows that form a tree in a grid's columns, such as an org chart, a bill of materials or a folder tree. A row opens to show the rows under it, and the first column shows each row's level. It sorts, filters, pages and edits as a DataGrid does, with its open rows in the URL so it works on static pages too.
A flat list with parent keys
Pass every row as Items, and set ItemParentKey to each row's parent's id, as most databases store it. A row with no parent, or one that isn't in the list, is a top row. ItemExpanded chooses the rows that start open.
Static
Preview
Code
@* A flat list of people, each with a manager's id, as an HR table holds them; the top level open. *@
<TreeList Items="_people" ItemKey="p => p.Id.ToString()" ItemParentKey="p => p.ManagerId?.ToString()"
ItemExpanded="p => p.ManagerId is null" QueryPrefix="org-" Caption="People">
<Columns>
<PropertyColumn Property="p => p.Name" Sortable Filterable />
<PropertyColumn Property="p => p.Title" Sortable />
<PropertyColumn Property="p => p.Location" Sortable Filterable />
<PropertyColumn Property="p => p.Started" Format="MMM yyyy" Sortable />
</Columns>
</TreeList>
{
private readonly Person[] _people =
[
new(1, null, "Maya Okafor", "Chief Executive Officer", "New York", new(2016, 3, 1)),
new(2, 1, "Daniel Reyes", "VP of Engineering", "Austin", new(2017, 6, 12)),
new(3, 2, "Priya Natarajan", "Engineering Manager, Platform", "Austin", new(2018, 9, 4)),
new(4, 3, "Tom Becker", "Senior Software Engineer", "Remote", new(2019, 1, 14)),
new(5, 3, "Lena Fischer", "Software Engineer", "Austin", new(2022, 5, 2)),
new(6, 3, "Omar Haddad", "Site Reliability Engineer", "Remote", new(2021, 8, 23)),
new(7, 2, "Grace Kim", "Engineering Manager, Apps", "New York", new(2019, 4, 8)),
new(8, 7, "Lucas Moreau", "Senior Software Engineer", "New York", new(2020, 2, 17)),
new(9, 7, "Aisha Bello", "Software Engineer", "Remote", new(2023, 1, 9)),
new(10, 1, "Sofia Rossi", "VP of Sales", "Chicago", new(2018, 1, 22)),
new(11, 10, "James O'Connor", "Account Executive", "Chicago", new(2020, 10, 5)),
new(12, 10, "Mei Lin", "Account Executive", "San Francisco", new(2022, 3, 28)),
new(13, 10, "Carlos Mendes", "Sales Engineer", "Remote", new(2021, 6, 14)),
new(14, 1, "Hannah Weiss", "Head of People", "New York", new(2019, 11, 11)),
new(15, 14, "Kwame Asante", "Recruiter", "New York", new(2023, 7, 31)),
new(16, 1, "Ravi Shah", "Chief Financial Officer", "New York", new(2020, 5, 18)),
new(17, 16, "Elena Petrova", "Controller", "New York", new(2021, 2, 1)),
];
}Add this example to a page with the izzy CLI:
izzy add component TreeList --at <file>:<line>Sorting orders each row's children among themselves, so a row never leaves its parent. Open rows are in the address, so a link or a reload keeps them.
Topics
- Filtering: Filters and search keep each match with the rows above it, so the user sees where it belongs.
- Open rows: Rows open from the address, from a link, or from C# when the open rows are bound.
- Selection: Checkboxes select rows, and checking a row checks the rows under it.
- Editing: Rows are edited as in a DataGrid, an action adds a row under another, and Move puts a row under a new parent.
- Totals and export: Rows show the totals of their branches, the footer the totals of every match, and exports keep the tree's levels.
- Server data: Rows load from your database a level at a time, as the user opens them, and large trees draw only the rows in view.
- Adaptability: On a phone or in a narrow panel, the tree list hides the columns that don't fit and shows their values under the row.
Nested rows and icons
For rows that hold their children, pass the top rows as Items and set ItemChildren. ItemIcon draws an icon before a row's value in the first column, and is told whether the row is open.
Static
Preview
Code
@* Nested folders and files, as a file manager shows them; each folder's icon open or closed. *@
<TreeList Items="_files" ItemKey="f => f.Path" ItemChildren="f => f.Children" ItemIcon="Icon"
ItemExpanded="StartsOpen" QueryPrefix="files-" Caption="Files">
<Columns>
<PropertyColumn Property="f => f.Name" Sortable />
<PropertyColumn Property="f => f.Modified" Format="MMM d, yyyy" Sortable />
<PropertyColumn Property="f => f.Kind" Sortable />
<TemplateColumn Title="Size" SortBy="f => f.Bytes" Align="CellAlign.End" Sortable>Size(context.Bytes)</TemplateColumn>
</Columns>
</TreeList>
{
private static bool StartsOpen(FileEntry entry) => entry.Path == "/Projects";
private static IconData? Icon(FileEntry entry, bool open) =>
entry.Children is null ? entry.Kind == "Spreadsheet" ? Lucide.FileSpreadsheet : entry.Kind == "Image" ? Lucide.FileImage : Lucide.FileText
: open ? Lucide.FolderOpen : Lucide.Folder;
private static string Size(long? bytes) => bytes switch
{
null => "",
< 1024 * 1024 => $"{bytes / 1024.0:0} KB",
_ => $"{bytes / (1024.0 * 1024):0.0} MB",
};
private readonly FileEntry[] _files =
[
Folder("/Projects", new(2026, 11, 3),
[
Folder("/Projects/Website redesign", new(2026, 11, 3),
[
File("/Projects/Website redesign/Brief.docx", "Document", new(2026, 9, 14), 48_200),
File("/Projects/Website redesign/Homepage mockup.png", "Image", new(2026, 10, 30), 2_874_000),
File("/Projects/Website redesign/Budget.xlsx", "Spreadsheet", new(2026, 11, 3), 31_500),
]),
Folder("/Projects/Q4 launch", new(2026, 10, 21),
[
File("/Projects/Q4 launch/Launch plan.docx", "Document", new(2026, 10, 2), 61_900),
File("/Projects/Q4 launch/Press list.xlsx", "Spreadsheet", new(2026, 10, 21), 22_400),
]),
]),
Folder("/Finance", new(2026, 11, 1),
[
File("/Finance/2026 forecast.xlsx", "Spreadsheet", new(2026, 11, 1), 118_300),
File("/Finance/Expense policy.pdf", "Document", new(2026, 2, 6), 402_000),
]),
File("/Notes.txt", "Document", new(2026, 11, 7), 3_100),
];
}Details
The first column shows each row's level: an indent, a chevron on a row with rows under it, an optional ItemIcon, then the column's value. The chevron in its header opens or closes every row.
Open rows are in the address (?open=key, repeated; * for all, !key for one closed), so a static page opens a row by a link. Bind ExpandedItems on an interactive page to keep them in the component. ExpandAll and ItemExpanded choose the rows that start open.
Sorting orders each row's children among themselves; a row never leaves its parent. Filtering and search keep the matches and the rows above them, muted, with their branches open; FilterBranch keeps the rows under a match too. Pages count top rows, so a branch is never split.
For rows in a database, set ItemsProvider instead of Items: it's asked for the top rows, then for each open row's children, with that row's key in request.Parent, and request.ToTreeResult answers it. ItemHasChildren gives rows their chevrons before their children load. A row shows up to ChildRowLimit rows under it (200), then Show more.
With SelectionMode.Multiple, checking a row checks the rows under it, and a row with some of them checked shows a mixed box (Cascade="false" makes each box its own). A checked row stands for its branch, drawn or not: Selection.ApplyTree finds every row it means. SelectOnClick selects a row by a click on it.
Parts
Written inside TreeList. The API page lists their parameters.
AddChildAction: aTreeListrow's Add child action: adds a row under it, from the tree list'sNewChild, in the edit dialog or in place under it, and opens it so the new row shows.MoveAction: aTreeListrow's Move action: a dialog to choose the row it goes under, or the top level, for the tree list'sOnReparentto save.
Mode support
| Feature | Static | Interactive |
|---|---|---|
| Nested rows from a flat list with a parent key, or from children | Yes | Yes |
| Open rows in the URL, so a static page opens them by a link | Yes | Yes |
| Open rows bound to C# | No | Yes |
| Sorting within each row's children | Yes | Yes |
| Filters and search that keep the rows above a match | Yes | Yes |
| Pages of top rows, so a branch is never split | Yes | Yes |
| Rows from a database a level at a time, loaded as rows open | Yes | Yes |
| Up to 200 rows under a row, then Show more | Yes | Yes |
| Virtual rows over every open branch, on interactive pages | No | Yes |
| Checking a row checks the rows under it, open or not | Yes | Yes |
| A row's total of its branch, and the footer's of every match | Yes | Yes |
| Excel and CSV export that keeps the tree's levels | Yes | Yes |
| Editing as in a DataGrid, and adding a row under another | Yes | Yes |
| Moving a row under a new parent from a dialog, with no script needed | Yes | Yes |
| Dragging a row before, after or into another | Yes | Yes |
| Treegrid keys: Right opens a row, Left closes it or goes to its parent | Yes | Yes |
Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.
Without JavaScript
Every page starts as plain HTML: before IzzyBlazor's script loads on a static page, while an interactive page prerenders, and with JavaScript off. With JavaScript off, each chevron is a link that loads the page with that row open or closed; there's no select-all checkbox, checking a row doesn't check the rows under it, and filters apply when you press Apply.
Accessibility
- With script, the table is a treegrid: each row has its level, its place among its siblings and, with rows under it, whether it's open.
- Each chevron is named for its row ("Expand Ada Lovelace"), and the header's for what it does ("Expand all rows").
- A row kept only because a match is under it is muted, and still read.
Keyboard navigation
In the first column
| Press this key | To do this |
|---|---|
| Right | Open the row; on an open row, move right |
| Left | Close the row; on a closed row, move to its parent |
Parameters
| Prop | Type | Default |
|---|---|---|
ItemChildrenA row's children, for nested data: Items are then the top rows. | Func<TItem, IEnumerable<TItem>?>? | |
ItemParentKeyA row's parent's key, for a flat list such as a table with a ParentId: Items are then every row, and a row whose parent key is null, or isn't another row's key, is a top row. | Func<TItem, string?>? | |
@bind-ExpandedItemsWhich rows are open, by key; "*" opens every row, "!*" closes every row, and "!key" closes one. | IReadOnlyList<string>? | |
ExpandAllWhether every row starts open. | bool | false |
ItemExpandedStarts chosen rows open, such as the top level of an org chart. | Func<TItem, bool>? | |
ItemIconAn icon before a row's value in the first column; the flag says whether the row is open, for an open or a closed folder. | Func<TItem, bool, IconData?>? | |
FilterBranchWhile filtering or searching, keeps the rows under a match too, not only the match and the rows above it: a search for a department shows its people. | bool | false |
ItemHasChildrenWhether a row has rows under it, so it gets a chevron before they load, with an ItemsProvider. | Func<TItem, bool>? | |
ChildRowLimitThe most rows shown under one row; a Show more row after them shows as many again. | int | 200 |
CascadeWith SelectionMode.Multiple, checking a row checks the rows under it, and a row with some of them checked shows a mixed box. | bool | true |
NewChildA new row's starting values under the row given, such as its parent's id set. | Func<TItem, TItem>? | |
ItemMovableWhich rows can be moved; all of them when it's not set. | Func<TItem, bool>? | |
MoveByDragGives each row a handle to drag it before, after or into another row, never into its own branch. | bool | false |
GroupsProviderWith an ItemsProvider, works out the footer's aggregates (a column's Aggregate) over every row the filters match, as the rows it holds are only a page's: answer it with request.ToResultAsync over the same query. | Func<DataGroupRequest<TItem>, ValueTask<DataGroupResult>>? | |
VirtualizeDraws only the rows in view, as they scroll, for a tree with many rows open: every visible row is worked out from Items, and opening a row keeps the place. | bool | false |
RowHeightThe height of every row, in pixels, with Virtualize. | double | 48 |
SmallScreenWhat it does when its columns don't fit its width. | DataGridSmallScreen | DataGridSmallScreen.Scroll |
NonceA CSP nonce for the style element that holds the widths where columns hide. | string? | computed |
EditModeHow a row is edited. | DataGridEditMode | DataGridEditMode.None |
FindItemFinds a row that isn't among those loaded, by its key, for the edit dialog and the delete confirmation: a link to a row on another page, say. | Func<string, Task<TItem>>? | |
NewItemA new row's starting values. | Func<TItem>? | |
AddTextThe Add button's text, such as "Add customer". | string? | computed |
ItemEditableWhich rows can be edited; all of them when it's not set. | Func<TItem, bool>? | |
ItemDeletableWhich rows can be deleted; all of them when it's not set. | Func<TItem, bool>? | |
RowActionsWhether rows have their actions: Edit, Delete and an ActionColumn's. | bool | true |
@bind-EditKeyA link from another page can open the dialog and come back: /contacts?edit=42&return=/contacts/42 goes to return, a path on this site, when the dialog saves or closes, in place of the grid's page. | string? | |
EditCopyMakes the copy of a row that's edited, on an interactive page, in place of a shallow copy: for a type that holds what a copy mustn't share. | Func<TItem, TItem>? | |
EditDialogArranges the generated edit dialog's fields: an EditField for a column sets its place and its label, hint or span, and the library's components can go around them. | RenderFragment? | |
EditDialogFormYour own form in the edit dialog, in place of the generated one, for what isn't fields of the row, such as steps or a save across several records. | RenderFragment<DataGridEditFormContext<TItem>>? | |
EditColumnsThe columns the edit dialog's fields are laid out in, as Form's Columns. | int | 1 |
EditLayoutHow labels sit next to the edit dialog's fields, as Form's Layout. | FormLayout | FormLayout.Vertical |
EditDialogSizeThe edit dialog's size. | DialogSize? | computed |
EditDialogTitleThe edit dialog's title, from the row, which is the default for a new one. | Func<TItem, string>? | computed |
EditSaveTextThe edit dialog's submit button, from the row (none for a new one), so it says what happens: u => u is null ? "Send invite" : "Save". | Func<TItem, string>? | computed |
LayoutKeyRemembers how each person has arranged the columns, in a cookie under this name, so the server draws it on the first paint. | string? | |
@bind-LayoutHow the columns are arranged, in place of the cookie: bind it (@bind-Layout) to keep layouts yourself, such as per user in a database. | DataGridLayout? | |
LayoutSaveUrlWith script, an address the app maps to save a person's layout: the grid posts it there as JSON when it changes, for a static page that passes its own Layout. | string? | |
ResizableColumnsLets people resize columns: by dragging a handle at the header's end, by double-clicking it to fit, by Shift+Left and Shift+Right, or from the header's menu. | bool | false |
ReorderableColumnsLets people move columns: by dragging a header, by Alt+Left and Alt+Right, or from the header's menu, which can also freeze them. | bool | false |
ColumnPickerA button above the grid that opens a list of the columns, in the grid's order, each band's under it: tick to show or hide, search by title, drag a handle (or open its menu, or Alt+Up and Down) to move, and reset to the columns as declared. | bool | false |
ToolbarLabelsText beside the icons of the toolbar's own tools, for a grid people use now and then. | bool | false |
ExportCsvHrefA link in the toolbar, in a menu with ExportExcelHref and any DataGridExportFormat, to an endpoint that writes the rows as CSV with DataExport, for a grid that offers CSV besides Excel. | string? | |
ExportExcelHrefA link in the toolbar, in a menu with ExportCsvHref and any DataGridExportFormat, to an endpoint that writes the rows as an Excel workbook with DataExport. | string? | |
ToolbarContentThe page's own controls in the toolbar above the grid: ToolbarButton, ToolbarMenu and the like. | RenderFragment? | |
SearchableA search box in the toolbar, across the text columns. | bool | false |
SelectOnClickA click on a row selects it, with IzzyBlazor's script; clicks on its links, buttons and fields stay theirs. | bool | false |
WrapCellsWhether text too long for its column wraps onto more lines, making the row taller (true, the default), or stays on one line, ending in an ellipsis, with the whole text in a tooltip when a cell is hovered or focused. | bool | true |
@bind-SearchThe words searched for. | string? | |
SearchLabelThe search box's name and placeholder. | string? | "Search" |
FilterRowAdds a row of filters under the titles: a field for each column, then its filter button, which opens the column's panel, where the operator is chosen. | bool | false |
FilterBuilderAdds a Filter builder button to the toolbar, for groups of conditions no column's filter can hold. | bool | false |
ColumnsThe columns: PropertyColumn<T1, T2>, TemplateColumn<T> and DynamicColumn<T>, in ColumnBands if you like. | RenderFragment? | |
InitialSortThe sort when the URL has none, such as "name" or "-date" (descending). | string? | |
@bind-SortThe sort, such as "name" or "-date" (descending), or several in a DataGrid ("status,-date"); null for InitialSort. | string? | |
@bind-FilterThe filter: Filter.All of a condition per filtered column (contains for text, between for numbers, equals for dates, equals or in for choices), or null for none. | Filter? | |
FilterCaseHow text compares in the column filters and search. | FilterCase | FilterCase.IgnoreCase |
FilterPanelA row below the rows that lists the active filters, each with a button to remove it, and Clear for all of them. | bool | false |
CaptionThe table's name for screen readers (a visually hidden caption). | string? | |
RowClassA class for each row, such as one that highlights overdue orders. | Func<TItem, string?>? | |
RowHoverHighlights the row under the pointer, to help follow a wide one across. | bool | false |
StripedAlternating row backgrounds. | bool | false |
RowLinesA line between rows. | bool | true |
ColumnLinesA line between columns. | bool | false |
ShadedHeaderShades the header, and a DataGrid's FilterRow with it, so they read apart from the rows; its color is --ib-table-head-bg. | bool | false |
BorderedA rounded border around the table. | bool | true |
SizeRow height and text size. | ControlSize | ControlSize.Md |
MaxHeightA height limit: the rows scroll and the header stays in view. | Length? | |
RowHrefMakes each row a link, such as to the item's details page. | Func<TItem, string?>? | |
RowCurrentThe row for what the page is showing, such as the one whose details are in a panel beside the table: drawn as selected, and marked aria-current (on its link with RowHref). | Func<TItem, bool>? | |
RowLabelNames a row for screen readers, in its link and its checkbox. | Func<TItem, string>? | computed |
FilterFromQueryApplies a whole filter from the address (?filter=, with the QueryPrefix), as a FilterBuilder<T> on the page writes it, along with the columns' own. | bool | false |
ItemsThe items. | IEnumerable<TItem>? | |
ItemsProviderLoads the items yourself, in place of Items: the request has the range (and in a Table the sort, the filter and the columns as fields), so request.ToResultAsync(query, ...) or request.Apply(query) does the work. | Func<DataRequest<TItem>, ValueTask<DataResult<TItem>>>? | |
@bind-PageSizeItems per page. | int? | |
PageSizeOptionsSizes to choose from in a "Rows per page" menu in the footer, such as new[] { 10, 25, 50 }. | IReadOnlyList<int>? | |
@bind-PageThe page, from 1. | int? | |
PagingHow it moves through its pages when it has a PageSize: numbered pages (DataPaging.Pages, the default, which needs a total), or by cursor, with no total needed: First, Previous and Next (DataPaging.NextPrevious), a "Load more" button after the items (DataPaging.LoadMore, ListView only), or loading as the last item comes into view (DataPaging.LoadOnScroll). | DataPaging | DataPaging.Pages |
LoadMoreTextThe "Load more" button's text, such as "Load earlier". | string? | "Load more" |
@bind-CursorThe cursor of the page shown when paging by cursor (Paging); null for the first page. | string? | |
QueryPrefixPrefix for its query-string keys, so several can share a page: QueryPrefix="orders-" uses ?orders-page= (and a Table's ?orders-sort=). | string | "" |
EmptyContentShown when there are no items. | RenderFragment? | computed |
EmptyTextThe text when there are no items. | string? | "No items" |
NoMatchesTextA grid's text when its search matches no rows, with {0} for the words: "No customers match “{0}”". | string? | "No matches for “{0}”" |
NoMatchesContentShown in place of NoMatchesText when a grid's search matches no rows, with the words searched for as its context: an EmptyState with an icon and a line on what to try. | RenderFragment<string>? | |
ErrorContentShown in place of "Couldn't load the rows." when loading fails, before the Retry button. | RenderFragment? | |
ItemKeyA unique, stable key for each item, such as its id. | Func<TItem, string>? | computed |
LoadingShows it as loading: items dim, or placeholders show while there are none. | bool | false |
SelectionModeWhether items can be selected: one (a radio button on each) or several (a checkbox on each). | SelectionMode | SelectionMode.None |
SelectionNameThe form field name the selection posts under, read back as a Selection with [SupplyParameterFromForm(Name = ...)]. | string? | computed |
@bind-SelectionThe selected items: keys on any page, or every item matching the filter except some. | Selection? | |
ItemSelectableWhether an item can be selected; others show a disabled, unchecked box, and selecting the page or a range leaves them out. | Func<TItem, bool>? | |
SelectAllModeWhat the select-all checkbox selects: the items on this page, or every item the filters match, on any page. | SelectAllMode | SelectAllMode.Page |
SelectionActionsActions on the selection, in a bar above the items, disabled until something is selected (on a DataGrid with a toolbar, the bar takes the toolbar's place while something is). | RenderFragment<Selection>? | |
SelectAllLabelThe select-all checkbox's name for screen readers. | string? | "Select all rows" |
SelectRowLabelThe start of each item checkbox's name for screen readers, before the item's label. | string? | "Select" |
OnReparentSaves a row moved under another, or to the top level, from a MoveAction's dialog. | EventCallback<TreeListMove<TItem>> | |
OnSaveSaves an edited row. | EventCallback<DataGridSave<TItem>> | |
OnDeleteDeletes a row, once someone has confirmed it. | EventCallback<DataGridDelete<TItem>> |
Plus 17 item props and 4 common props.
Full APISee also
- DataGrid: runs admin screens and back-office lists: large sets of records people search, edit and export.
- TreeView: shows items nested in items, such as folders, as branches that open and close.