Tree table
vig-table vig-col ng-template[vigTableCell]
import { Table, TableColumn, TableCell } from '@vigdx/ui/table';Basic
items and an accessor of their children as rowChildren , e.g. (f: FileRow) => f.children : no wrapper type, no string paths. An array ( [] ) or null marks a leaf. The toggle sits in the rowHeader column (else the first one), indented by level; [(expandedRows)] holds the open rows, matched by rowId , so give rows a stable id. Sorting orders siblings within their parent: the hierarchy stays.
src | Folder | 5 KB |
|---|---|---|
app | Folder | 4 KB |
main.ts | TypeScript | 1 KB |
docs | Folder | 15 KB |
package.json | JSON | 3 KB |
README.md | Markdown | 6 KB |
Checkboxes
selectionMode="multiple" cascades in a tree table: checking a row checks its descendants (also collapsed ones), and a parent shows checked, unchecked or mixed from them. selection keeps the shape it has in any table, an array of your rows, and lists every checked row: implied checks (a parent you set, children loaded under a checked row) are written back into it, so the boxes, selection and the export always agree. rowSelectable locks rows: they show a disabled checkbox with their own state, the cascade passes through them, and their parent ignores them. [cascade]="false" makes every checkbox independent; single selects one row with a radio or a row click.
| Name | Kind | |
|---|---|---|
src | Folder | |
app | Folder | |
main.ts | TypeScript | |
docs | Folder | |
guide.md | Markdown | |
legacy.md | Markdown | |
package.json | JSON | |
README.md | Markdown |
0 rows checked; legacy.md is locked.
Lazy loading
rowChildren is undefined load their children with loadChildren(row, signal) on first expand, in the browser only (the server renders them busy, so hydration matches); [] or null marks a leaf. The row is aria-busy meanwhile, collapsing it aborts signal (pass it on to fetch ), and the answer of a cancelled or replaced loader is ignored. A rejected promise adds a row with a Retry button and is announced. Loaded children are kept per rowId across new items (also through an empty list while you refetch) and dropped for rows that leave the data; call reloadChildren(row?) when the server's data changed.
| Name | Items |
|---|---|
projects | 2 |
archive (fails once) | 2 |
notes.txt | 0 |
Filtering and paging
expandedRows (closing one while filtered is remembered until the filter changes), and its descendants stay reachable. The status announces how many rows match. The paginator pages the root rows, so a page can show more lines than rows when roots are expanded. exportCsv() exports every filtered row depth first, expanded or not.
src | Folder | 5 |
|---|---|---|
docs | Folder | 15 |
Virtual scrolling
virtualScroll renders only the rows in view: here 10,000 expanded rows. The window follows the rows on screen (expanded rows and their descendants), so expanding, collapsing, lazy loading, filtering and the cascading selection work as without it. The keys move by row index: End or Ctrl+End scrolls the last row into the window before it takes focus, and PageUp and PageDown move by a screen of the scroll area (a tree table that does not scroll itself leaves them to the page). The tab stop row and the focused row stay rendered wherever the view goes, and keys pressed while a row is on its way count from that row. Rows share one measured height and the columns keep their widths ( table-layout: fixed ), as in a flat virtual table.
| Kind | ||
|---|---|---|
folder-0 | Folder | 2401 KB |
file-0.ts | TypeScript | 0 KB |
file-1.ts | TypeScript | 1 KB |
file-2.ts | TypeScript | 2 KB |
file-3.ts | TypeScript | 3 KB |
file-4.ts | TypeScript | 4 KB |
file-5.ts | TypeScript | 5 KB |
file-6.ts | TypeScript | 6 KB |
file-7.ts | TypeScript | 7 KB |
file-8.ts | TypeScript | 8 KB |
file-9.ts | TypeScript | 9 KB |
file-10.ts | TypeScript | 10 KB |
file-11.ts | TypeScript | 11 KB |
file-12.ts | TypeScript | 12 KB |
file-13.ts | TypeScript | 13 KB |
file-14.ts | TypeScript | 14 KB |
file-15.ts | TypeScript | 15 KB |
file-16.ts | TypeScript | 16 KB |
file-17.ts | TypeScript | 17 KB |
file-18.ts | TypeScript | 18 KB |
file-19.ts | TypeScript | 19 KB |
file-20.ts | TypeScript | 20 KB |
file-21.ts | TypeScript | 21 KB |
file-22.ts | TypeScript | 22 KB |
file-23.ts | TypeScript | 23 KB |
file-24.ts | TypeScript | 24 KB |
file-25.ts | TypeScript | 25 KB |
file-26.ts | TypeScript | 26 KB |
file-27.ts | TypeScript | 27 KB |
file-28.ts | TypeScript | 28 KB |
file-29.ts | TypeScript | 29 KB |
file-30.ts | TypeScript | 30 KB |
file-31.ts | TypeScript | 31 KB |
file-32.ts | TypeScript | 32 KB |
file-33.ts | TypeScript | 33 KB |
file-34.ts | TypeScript | 34 KB |
file-35.ts | TypeScript | 35 KB |
file-36.ts | TypeScript | 36 KB |
file-37.ts | TypeScript | 37 KB |
file-38.ts | TypeScript | 38 KB |
With the other table features
- Column templates, sticky header, density, gridlines and stripes work as in any table; the toggle column wraps its cell template after the toggle.
- Saved state (
state) keeps the expanded rows byrowId, at any level: rows below a lazy level open once their parent loaded. - Context menu: a
[vigContextMenu]on the table handsrunthe typed row it opened on, nested rows included. - Server-side tables (
lazy): the server sorts, filters and pages the root rows; children load withloadChildrenin the order given. - Cell editing:
editablecolumns work at every level. Move to a cell with the arrow keys, then Enter, F2 or typing edits it;cellEditedhands you the nested row to replace in your data. - Not with tree rows:
vigTableRowExpansiontemplates,groupByandreorderableRowsare ignored (with a dev-mode warning), since rows expand into their children.
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="table"][data-part="toolbar"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="table"]
| Part | Element | data-state |
|---|---|---|
toolbar | — | |
search | — | |
filter-indicator | — | |
frame | — | |
loading | — | |
scroll | — | |
table | <table> . | — |
head | <thead> . | — |
header-cell | <th> ( aria-sort ; data-frozen="start|end" when frozen, like every frozen cell). | — |
resize-handle | role="separator" , resizableColumns ). | dragging |
sort | — | |
sort-priority | — | |
sort-priority-label | — | |
add-to-sort | — | |
filter-row | filterDisplay="row" ). | — |
filter-trigger | filterDisplay="menu" ). | — |
filter-panel | — | |
clear-selection | — | |
body | <tbody> . | — |
spacer | virtualScroll ): the aria-hidden row standing in for the rows above or below the rendered ones. | — |
group-header | groupBy ). | — |
row | selected | |
row-handle | reorderableRows ): drag it, Alt+ArrowUp/ArrowDown on it, or click it for its move menu. | — |
select | — | |
select-all | — | |
expand | — | |
cell | <td> or row-header <th> ( data-frozen="start|end" when frozen). | editing |
editor | editable column). | — |
editor-error | aria-describedby of the editor). | — |
expansion | — | |
toggle | rowChildren ; aria-expanded , no Tab stop of its own). | open, closed |
children-loading | — | |
children-error | — | |
retry | — | |
empty | — | |
paginator | vig-paginator (top and bottom). | — |
Accessibility
- Follows the WAI-ARIA APG treegrid pattern: the table takes
role="treegrid", named by itscaption, and its rowsaria-level,aria-setsize,aria-posinset(counting every root under a paginator) and, on parents,aria-expanded. With a selection, rows carryaria-selectedand the grid isaria-multiselectableinmultiplemode; the native checkboxes show mixed parents as indeterminate. With arowHeadercolumn, a row is named by its row-header cell. - The rows are one Tab stop (a roving tab index). ArrowDown and ArrowUp move between rows, ArrowRight opens a row or enters its first cell, ArrowLeft closes it or goes to its parent (both mirrored in right-to-left content), Home and End (also with Ctrl) jump to the first and last row, PageUp and PageDown move by a screen of rows, Enter is a row click (
rowClick, and the selection insinglemode) and Space selects (or, without selection, opens and closes). In a cell, the arrows move between cells, ArrowLeft from the first cell returns to the row, Home and End go to the row's first and last cell and Ctrl+Home and Ctrl+End to the column's first and last row. Enter or Space on the selection cell checks the row, and on an error row retries. The table is one Tab stop: its own controls in the rows (checkboxes, radios, the toggle, Retry) take no Tab stop of their own. Controls of your cell templates keep theirs; Enter or F2 on their cell moves focus into the first one, and Escape back to the cell, where the arrow keys move on (APG grid pattern). Alt and Cmd arrow combinations are left to the browser. - When the row with focus leaves the screen (its parent collapses, a filter changes, the data drops it), focus moves to its nearest ancestor on screen, else to the next row that stayed, never to the page.
- With
virtualScrollthe treegrid carriesaria-rowcountand every rendered rowaria-rowindex; the keys work by index, so a row outside the rendered window scrolls in and then takes focus. The tab stop row and the focused row stay rendered at their own place while the view moves, so Tab always reaches the grid and focus never falls back to the page. - The toggle is a button named "Expand row" or "Collapse row" with the row's name (
expandRowAriaLabel,collapseRowAriaLabel) andaria-expanded, so touch screen readers and voice control can open rows, but no Tab stop: the arrow keys do that for keyboard users. Its hit area is 24px, and on coarse pointers tree rows are at least 44px tall to fit a 44px one. Its chevron turns by CSS alone, so it follows a plaindir="rtl". A focused row draws an inset ring through its cells (an outline on a table row is not painted by every engine), focused cells an outline; in forced-colors mode every cell of the focused row outlines itself in Highlight. - A row whose children load is
aria-busyand described as loading; a failed load is announced through the table's status region and adds a row that retries with Enter, Space or its Retry button.
API
Table
vig-tableData table for the backoffice list screens: client-side or lazy
(server-side) sorting — by one column or several (sortMode="multiple") —
column filters (columns with a filter, as a filter row or filter menus) and
a global filter, pagination, checkbox or radio selection (a row click
selects too), group subheaders, expandable rows, column visibility, CSV
export, persisted state (state), loading and empty states.
With rowChildren (or loadChildren) it becomes a tree table: the
items are the root rows and the table an APG treegrid. virtualScroll
renders only the rows in view, for tens of thousands of rows.
Columns can be resized (resizableColumns), reordered
(reorderableColumns) and frozen (vig-col frozen), also in a virtual
table. Cells of editable columns are edited in place (cellEdited), and
reorderableRows lets users move rows (rowReordered); the table never
changes your items itself.
resize-handle dragging
| Name | Type | Default | Description |
|---|---|---|---|
caption | string | undefined | undefined | Accessible table name, rendered as a visually hidden caption. |
cascade | boolean | true | Tree table with |
clearSelectionAriaLabel | string | undefined | undefined | Name of the single-selection column's clear button (i18n). |
collapseRowAriaLabel | string | undefined | undefined | — |
columnResizeMode | TableColumnResizeMode | 'fit' |
|
columnVisibility | Readonly<Record<string, boolean>> | — | Visibility per column |
emptyMessage | string | undefined | undefined | — |
expandedRows | T[] | [] | Expanded rows of a table with a |
expandRowAriaLabel | string | undefined | undefined | — |
filterDisplay | TableFilterDisplay | 'row' |
|
filters | TableFilters | — | Column filters by column |
first | number | 0 | — |
globalFilter | string | '' | Text searched ( |
globalFilterFields | readonly string[] | undefined | undefined | Column fields the global filter searches; every visible column with a |
gridlines | boolean | false | Lines between columns as well as rows. |
groupBy | string | undefined | undefined | Inserts a subheader row whenever this property's value changes. |
items | readonly T[] | [] | — |
labels | Partial<TableLabels> | — | Texts of the filter UI, multi-sort, toolbar and result status (i18n); locale defaults. |
lazy | boolean | false | Rows are already paged/sorted by the server; state changes emit lazyLoad. |
loadChildren | TableChildrenLoader<T> | undefined | undefined | Fetches the children of rows whose |
loading | boolean | false | — |
loadingAriaLabel | string | undefined | undefined | — |
paginator | boolean | false | Renders the embedded paginator and (non-lazy) slices the rows. |
paginatorLabels | PaginatorLabels | — | — |
paginatorOptions | TablePaginatorOptions | — | Paginator placement ( |
paginatorReportPosition | PaginatorReportPosition | 'start' | — |
paginatorSize | PaginatorSize | 'sm' | — |
reorderableColumns | boolean | false | Lets users reorder the columns with a |
reorderableRows | boolean | false | Lets users move rows: drag a row by its handle (a long press on touch
screens), press Alt+ArrowUp/ArrowDown (Alt+Home/End) on the handle or a
cell, or pick a move from the handle's menu. Moves are announced and
reported as |
resizableColumns | boolean | false | Adds a resize handle to the header of every column with a |
rowChildren | TableChildrenAccessor<T> | undefined | undefined | Makes the table a tree table: the children of a row, e.g.
The table then is an APG treegrid: a toggle in the row-header column
(else the first column) expands rows ( |
rowExpandable | ((row: T) => boolean) | undefined | undefined | Which rows get an expansion toggle; every row when unset. |
rowHover | boolean | false | Pointer feedback (hover fill + cursor) for rowClick-driven tables. |
rowId | ((row: T) => unknown) | undefined | undefined | Row identity for selection and tracking, e.g. |
rows | number | 10 | — |
rowSelectable | ((row: T) => boolean) | undefined | undefined | Which rows can be selected; every row when unset. The others show a disabled checkbox or radio with their own state, and a row click or the header checkbox leaves them as they are. |
rowsPerPageOptions | readonly number[] | [] | — |
scrollHeight | string | undefined | undefined | Max height of the scrolling body area, any CSS length, e.g. |
scrollRegionAriaLabel | string | undefined | undefined | Name of the scroll region when there is no |
selectAllAriaLabel | string | undefined | undefined | — |
selection | T[] | [] | Selected rows; holds at most one entry in single mode. |
selectionMode | "none" | "single" | "multiple" | 'none' |
|
selectRowAriaLabel | string | undefined | undefined | — |
size | TableSize | 'md' | Row density: vertical cell padding of the body rows. |
sort | TableSort | null | null | The sorted column; in |
sortAscendingAnnouncement | string | undefined | undefined | Status announced after an ascending sort; |
sortDescendingAnnouncement | string | undefined | undefined | Status announced after a descending sort; |
sortIndicator | TableSortIndicator | 'always' |
|
sortMode | "single" | "multiple" | 'single' |
|
sorts | TableSort[] | [] | Every sorted column in priority order: the source of truth in
|
state | TableStateOptions | undefined | undefined | Keeps sort, filters, page, page size, column visibility and expanded rows
across visits: a storage key ( |
stickyHeader | boolean | false | Keeps the header row in view while the body scrolls (set |
striped | boolean | false | Alternating row fills. |
toolbar | TableToolbar | — | Built-in controls above the table: |
totalRecords | number | undefined | undefined | Total row count on the server (lazy mode). |
virtualScroll | TableVirtualScroll | false | Renders only the body rows in view (and a few around them), for large
flat or tree tables: |
| Name | Payload | Description |
|---|---|---|
cellEdited | TableCellEditEvent<T> | A committed cell edit of an |
columnReordered | TableColumnReorderEvent | A column the user moved, by dragging its header or from the column menu. |
columnResized | TableColumnResizeEvent | A column the user resized (pointer drag released, or a key press on its handle). |
columnVisibilityChange | Readonly<Record<string, boolean>> | Visibility per column |
expandedRowsChange | T[] | Expanded rows of a table with a |
filtersChange | TableFilters | Column filters by column |
firstChange | number | — |
globalFilterChange | string | Text searched ( |
lazyLoad | TableLazyLoadEvent | — |
rowClick | T | Fired on any row click (all selection modes) — e.g. navigate to detail. Pointer shortcut only; give keyboard users an explicit control in a cell. |
rowReordered | TableRowReorderEvent<T> | A row the user moved ( |
rowsChange | number | — |
selectionChange | T[] | Selected rows; holds at most one entry in single mode. |
sortChange | TableSort | null | The sorted column; in |
sortsChange | TableSort[] | Every sorted column in priority order: the source of truth in
|
| Signature | Description |
|---|---|
clearFilters(): void | Clears every column filter and the global filter, including values still being typed. |
exportCsv(options: TableCsvExportOptions = {}): string | Exports the rows as CSV and, in the browser, downloads the file. By
default: the visible columns with a |
isColumnVisible(column: TableColumn): boolean | Whether the column shows: its |
isExpanded(row: T): boolean | — |
isSelected(row: T): boolean | Whether the row is selected; with a cascading tree selection, whether it shows checked. |
reloadChildren(row?: T): void | Forgets what |
scrollToIndex(index: number): void | Scrolls the display row at |
scrollToRow(row: T): boolean | Scrolls |
setColumnVisible(column: TableColumn, visible: boolean): void | Shows or hides a column (writes |
trackRow(row: T): unknown | — |
TableColumn
vig-colDeclares one table column. Renders nothing itself — vig-table reads the inputs and the optional cell template:
Example :<vig-col field="name" header="Name" [sortable]="true" />
<vig-col header="Actions">
<ng-template vigTableCell let-row let-i="rowIndex">…</ng-template>
</vig-col>| Name | Type | Default | Description |
|---|---|---|---|
align | "start" | "center" | "end" | "left" | "right" | 'left' | Text alignment of the column's cells and header. |
editable | boolean | false | Lets users edit the column's cells (needs a |
editType | TableCellEditType | undefined | undefined | The default editor of an |
field | string | undefined | undefined | Property read from the row for display and client-side sorting. |
filter | TableColumnFilterConfig | undefined | undefined | Makes the column filterable (needs a |
frozen | TableColumnFrozen | undefined | undefined | Keeps the column in view while the table scrolls horizontally, pinned to
the inline |
header | string | '' | — |
hidden | boolean | false | Starts the column hidden; the column menu or |
maxWidth | number | undefined | undefined | Widest width a resize gives the column, in px; unlimited by default. |
minWidth | number | undefined | undefined | Narrowest width a resize leaves the column, in px; 48 by default. |
resizable | boolean | undefined | undefined | Gives the column a resize handle ( |
rowHeader | boolean | false | Renders this column's cells as row headers ( |
sortable | boolean | false | — |
validate | TableCellValidator | undefined | undefined | Checks an edited value before it is committed: an error message keeps
the editor open showing it, |
value | TableValueAccessor | undefined | undefined | Typed accessor of the cell value, e.g. |
width | string | undefined | undefined | Any CSS width, e.g. '12rem' or '20%'. |
Templates and directives
| Selector | Export | Description |
|---|---|---|
[vigTableCell] | TableCell | Marks an ng-template as a column's custom cell. The explicit marker keeps
the query away from the TemplateRefs Angular creates for control-flow
blocks (@if/@for) around the template. Like every directive, it only
applies when the consuming component imports |