Skip to content

Grid

Since v0.1.0

Directive that automatically registers the Angular adapter with tbw-grid elements.

This directive eliminates the need to manually register the adapter in your component constructor. Simply import this directive and it will handle adapter registration.

import { Component } from '@angular/core';
import { Grid } from '@toolbox-web/grid-angular';
@Component({
selector: 'app-root',
imports: [Grid],
template: `
<tbw-grid [rows]="rows" [gridConfig]="config" [customStyles]="myStyles">
<!-- column templates -->
</tbw-grid>
`
})
export class AppComponent {
rows = [...];
config = {...};
myStyles = `.my-class { color: red; }`;
}

The directive automatically:

  • Creates a GridAdapter instance
  • Registers it with the GridElement
  • Injects custom styles into the grid
  • Handles cleanup on destruction

In single-version apps the directive matches the bare <tbw-grid> tag. When two different grid versions share a page, the second-loaded bundle registers under a version-suffixed tag (e.g. <tbw-grid-v2-15-0>). Because Angular matches selectors at compile time, a runtime-only tag cannot be matched by tag name. The directive therefore also matches the stable [data-tbw-grid] attribute, so a suffixed grid can opt in by adding it literally:

<tbw-grid-v2-15-0 data-tbw-grid [rows]="rows" [gridConfig]="config"></tbw-grid-v2-15-0>

Read the concrete tag from DataGridElement.activeTag of the bundle you imported. See the multi-version coexistence guide.

PropertyTypeDescription
customStylesInputSignal<string | undefined>Custom CSS styles to inject into the grid. Use this to style custom cell renderers, editors, or detail panels.
sortableInputSignal<boolean | undefined>Grid-wide sorting toggle. When false, disables sorting for all columns regardless of their individual sortable setting. When true (default), columns with sortable: true can be sorted.
filterableInputSignal<boolean | undefined>Grid-wide filtering toggle. When false, disables filtering for all columns regardless of their individual filterable setting. When true (default), columns with filterable: true can be filtered.
selectableInputSignal<boolean | undefined>Grid-wide selection toggle. When false, disables selection for all rows/cells. When true (default), selection is enabled based on plugin mode.
loadingInputSignal<boolean | undefined>Show a loading overlay on the grid. Use this during initial data fetch or refresh operations.
rowsInputSignal<any[] | undefined>The data rows to display in the grid.
columnsInputSignal<ColumnShorthand<any>[] | undefined>Column configuration array.
columnDefaultsInputSignal<Partial<ColumnConfig<any>> | undefined>Default column properties applied to every column in columns. Individual column properties override these defaults.
fitModeInputSignal<FitMode | undefined>Column sizing strategy.
columnInferenceInputSignal<ColumnInferenceMode | undefined>How automatic column inference combines with explicitly provided columns.
gridConfigInputSignal<GridConfig<any> | undefined>Grid configuration object with optional Angular-specific extensions.
selectionInputSignal<row | SelectionConfig<any> | cell | range | undefined>Enable cell/row/range selection.
editingInputSignal<boolean | click | dblclick | manual | EditingConfig | undefined>Enable inline cell editing.
clipboardInputSignal<boolean | ClipboardConfig | undefined>Enable clipboard copy/paste. Requires selection to be enabled.
contextMenuInputSignal<boolean | ContextMenuConfig | undefined>Enable right-click context menu.
multiSortInputSignal<boolean | multi | MultiSortConfig | single | undefined>Enable multi-column sorting.
filteringInputSignal<boolean | FilterConfig<any> | undefined>Enable column filtering.
reorderColumnsInputSignal<boolean | ReorderConfig | undefined>Enable column drag-to-reorder.
visibilityInputSignal<boolean | VisibilityConfig | undefined>Enable column visibility toggle panel.
pinnedColumnsInputSignal<boolean | undefined>Enable pinned/sticky columns. Columns are pinned via the sticky column property.
groupingColumnsInputSignal<boolean | GroupingColumnsConfig | undefined>Enable multi-level column headers (column groups).
columnVirtualizationInputSignal<boolean | ColumnVirtualizationConfig | undefined>Enable horizontal column virtualization for wide grids.
reorderRowsInputSignal<boolean | RowReorderConfig | undefined>Enable row drag-to-reorder.
rowDragDropInputSignal<boolean | RowDragDropConfig<any> | undefined>Enable row drag-and-drop within and across grids.
groupingRowsInputSignal<GroupingRowsConfig | undefined>Enable row grouping by field values.
pinnedRowsInputSignal<boolean | PinnedRowsConfig | undefined>Enable pinned rows (aggregation/status bar).
treeInputSignal<boolean | TreeConfig | undefined>Enable hierarchical tree view.
masterDetailInputSignal<MasterDetailConfig | undefined>Enable master-detail expandable rows.
responsiveInputSignal<boolean | ResponsivePluginConfig<unknown> | undefined>Enable responsive card layout for narrow viewports.
undoRedoInputSignal<boolean | UndoRedoConfig | undefined>Enable undo/redo for cell edits. Requires editing to be enabled.
exportFeatureInputSignal<boolean | ExportConfig | undefined>Enable CSV/JSON export functionality.
printInputSignal<boolean | PrintConfig | undefined>Enable print functionality.
pivotInputSignal<PivotConfig | undefined>Enable pivot table functionality.
serverSideInputSignal<ServerSideConfig | undefined>Enable server-side data operations.
tooltipInputSignal<boolean | TooltipConfig | undefined>Controls the tooltip behavior for the grid.
cellClickOutputEmitterRef<CellClickDetail<any>>Emitted when a cell is clicked.
rowClickOutputEmitterRef<RowClickDetail<any>>Emitted when a row is clicked.
cellActivateOutputEmitterRef<CellActivateDetail<any>>Emitted when a cell is activated (Enter key or double-click).
cellChangeOutputEmitterRef<CellChangeDetail<any>>Emitted when a cell value changes (before commit).
cellCommitOutputEmitterRef<CellCommitEvent<unknown, unknown>>Emitted when a cell value is committed (inline editing). Provides the row, field, new value, and change tracking information.
cellCancelOutputEmitterRef<CellCancelDetail>Emitted when a cell edit is cancelled (Escape, click outside without commit, or editor.cancel()).
editOpenOutputEmitterRef<EditOpenDetail<any>>Emitted when a cell editor opens.
beforeEditCloseOutputEmitterRef<BeforeEditCloseDetail<any>>Emitted before an editor closes. Useful for last-chance validation.
editCloseOutputEmitterRef<EditCloseDetail<any>>Emitted after an editor closes (whether committed or cancelled).
dirtyChangeOutputEmitterRef<DirtyChangeDetail<any>>Emitted when the dirty / changed-rows state transitions.
dataChangeOutputEmitterRef<DataChangeDetail>Emitted when row data is replaced (e.g. via the rows setter).
rowCommitOutputEmitterRef<RowCommitEvent<unknown>>Emitted when a row’s values are committed (bulk/row editing). Provides the row data and change tracking information.
changedRowsResetOutputEmitterRef<ChangedRowsResetDetail<unknown>>Emitted when the changed rows are reset.
sortChangeOutputEmitterRef<SortChangeDetail>Emitted when sort state changes.
filterChangeOutputEmitterRef<FilterChangeDetail>Emitted when filter values change.
columnResizeOutputEmitterRef<ColumnResizeDetail>Emitted when a column is resized.
columnResizeResetOutputEmitterRef<ColumnResizeResetDetail>Emitted when a column’s width is reset (double-click on the resize handle).
columnMoveOutputEmitterRef<ColumnMoveDetail>Emitted when a column is moved via drag-and-drop.
columnVisibilityOutputEmitterRef<ColumnVisibilityDetail>Emitted when a column is shown or hidden — either via the visibility sidebar, grid.toggleColumnVisibility(field), grid.setColumnVisible(field, visible), or grid.showAllColumns().
columnStateChangeOutputEmitterRef<GridColumnState>Emitted when column state changes (resize, reorder, visibility).
selectionChangeOutputEmitterRef<SelectionChangeDetail>Emitted when selection changes.
rowMoveOutputEmitterRef<RowMoveDetail<any>>Emitted when a row is moved via drag-and-drop.
rowDragStartOutputEmitterRef<RowDragStartDetail<any>>Emitted when a row drag starts. Cancelable via event.preventDefault().
rowDragEndOutputEmitterRef<RowDragEndDetail<any>>Emitted when a row drag ends (after drop or cancel).
rowDropOutputEmitterRef<RowDropDetail<any>>Emitted on the target grid when rows are dropped from another grid. Cancelable via event.preventDefault().
rowTransferOutputEmitterRef<RowTransferDetail<any>>Emitted on BOTH source and target grids after a successful cross-grid row transfer.
groupToggleOutputEmitterRef<GroupToggleDetail>Emitted when a group is expanded or collapsed.
groupExpandOutputEmitterRef<GroupExpandDetail>Emitted when a group is expanded.
groupCollapseOutputEmitterRef<GroupCollapseDetail>Emitted when a group is collapsed.
treeExpandOutputEmitterRef<TreeExpandDetail<any>>Emitted when a tree node is expanded.
detailExpandOutputEmitterRef<DetailExpandDetail>Emitted when a detail panel is expanded or collapsed.
responsiveChangeOutputEmitterRef<ResponsiveChangeDetail>Emitted when responsive mode changes (table ↔ card).
contextMenuOpenOutputEmitterRef<ContextMenuOpenDetail>Emitted when the context menu opens.
copyOutputEmitterRef<CopyDetail>Emitted when cells are copied to clipboard.
pasteOutputEmitterRef<PasteDetail>Emitted when cells are pasted from clipboard.
undoOutputEmitterRef<UndoRedoDetail>Emitted when an undo action is performed.
redoOutputEmitterRef<UndoRedoDetail>Emitted when a redo action is performed.
exportCompleteOutputEmitterRef<ExportCompleteDetail>Emitted when export completes.
printStartOutputEmitterRef<PrintStartDetail>Emitted when print starts.
printCompleteOutputEmitterRef<PrintCompleteDetail>Emitted when print completes.
tbwScrollOutputEmitterRef<TbwScrollDetail>Emitted (rAF-batched) when the grid’s viewport is scrolled vertically.
renderOutputEmitterRef<RenderDetail>Emitted once at the end of every render-scheduler flush, after all plugin afterRender hooks have run and ready() has resolved.
// In your component
customStyles = `
.my-detail-panel { padding: 16px; }
.my-status-badge { border-radius: 4px; }
`;
<tbw-grid [customStyles]="customStyles">...</tbw-grid>

Grid-wide sorting toggle. When false, disables sorting for all columns regardless of their individual sortable setting. When true (default), columns with sortable: true can be sorted.

This is a core grid config property, not a plugin feature. For multi-column sorting, also add the [multiSort] feature.

Default: true

<!-- Disable all sorting -->
<tbw-grid [sortable]="false" />
<!-- Enable sorting (default) - columns still need sortable: true -->
<tbw-grid [sortable]="true" />
<!-- Enable multi-column sorting -->
<tbw-grid [sortable]="true" [multiSort]="true" />

Grid-wide filtering toggle. When false, disables filtering for all columns regardless of their individual filterable setting. When true (default), columns with filterable: true can be filtered.

Requires the FilteringPlugin to be loaded.

Default: true

<!-- Disable all filtering -->
<tbw-grid [filterable]="false" [filtering]="true" />
<!-- Enable filtering (default) -->
<tbw-grid [filterable]="true" [filtering]="true" />

Grid-wide selection toggle. When false, disables selection for all rows/cells. When true (default), selection is enabled based on plugin mode.

Requires the SelectionPlugin to be loaded.

Default: true

<!-- Disable all selection -->
<tbw-grid [selectable]="false" [selection]="'range'" />
<!-- Enable selection (default) -->
<tbw-grid [selectable]="true" [selection]="'range'" />

Show a loading overlay on the grid. Use this during initial data fetch or refresh operations.

For row/cell loading states, access the grid element directly:

  • grid.setRowLoading(rowId, true/false)
  • grid.setCellLoading(rowId, field, true/false)

Default: false

<!-- Show loading during data fetch -->
<tbw-grid [loading]="isLoading" [rows]="rows" />
isLoading = true;
ngOnInit() {
this.dataService.fetchData().subscribe(data => {
this.rows = data;
this.isLoading = false;
});
}

The data rows to display in the grid.

Accepts an array of data objects. Each object represents one row. The grid reads property values for each column’s field from these objects.

<tbw-grid [rows]="employees()" [gridConfig]="config" />

Column configuration array.

Accepts either full ColumnConfig objects or shorthand strings such as 'name' or 'salary:number'. Shorthands auto-generate human-readable headers from the field name.

Shorthand for setting columns without wrapping them in a full gridConfig. If both columns and gridConfig.columns are set, columns takes precedence (see configuration precedence system).

<tbw-grid [rows]="data" [columns]="['id:number', 'name', { field: 'status', editable: true }]" />

<tbw-grid
[columnDefaults]="{ sortable: true, resizable: true }"
[columns]="[{ field: 'id', sortable: false }, { field: 'name' }]"
/>

Column sizing strategy.

  • 'stretch' (default) — columns stretch to fill available width
  • 'fixed' — columns use their declared widths; enables horizontal scrolling
  • 'auto-fit' — columns auto-size to content, then stretch to fill

Default: 'stretch'

<tbw-grid [rows]="data" fitMode="fixed" />
<tbw-grid [rows]="data" [fitMode]="dynamicMode()" />

How automatic column inference combines with explicitly provided columns.

  • 'auto' (default): infer only when no columns are provided.
  • 'merge': always infer from data, then overlay provided columns by field.
<tbw-grid [rows]="data" columnInference="merge" />
<tbw-grid [rows]="data" [columnInference]="mode()" />

Grid configuration object with optional Angular-specific extensions.

Accepts Angular-augmented GridConfig from @toolbox-web/grid-angular. You can specify Angular component classes directly for renderers and editors.

Component classes must implement the appropriate interfaces:

  • Renderers: CellRenderer<TRow, TValue> - requires value() and row() signal inputs
  • Editors: CellEditor<TRow, TValue> - adds commit and cancel outputs
// Simple config with plain renderers
config: GridConfig = {
columns: [
{ field: 'name', header: 'Name' },
{ field: 'active', type: 'boolean' }
],
typeDefaults: {
boolean: { renderer: (ctx) => ctx.value ? '' : '' }
}
};
// Config with component classes
config: GridConfig<Employee> = {
columns: [
{ field: 'name', header: 'Name' },
{ field: 'bonus', header: 'Bonus', editable: true, editor: BonusEditorComponent }
]
};
<tbw-grid [gridConfig]="config" [rows]="employees"></tbw-grid>

Enable cell/row/range selection.

Requires feature import:

import '@toolbox-web/grid-angular/features/selection';
<!-- Shorthand - just the mode -->
<tbw-grid [selection]="'range'" />
<!-- Full config object -->
<tbw-grid [selection]="{ mode: 'range', checkbox: true }" />

Enable inline cell editing.

Requires feature import:

import '@toolbox-web/grid-angular/features/editing';
<!-- Enable with default trigger (dblclick) -->
<tbw-grid [editing]="true" />
<!-- Specify trigger -->
<tbw-grid [editing]="'click'" />
<tbw-grid [editing]="'dblclick'" />
<tbw-grid [editing]="'manual'" />
<!-- Full config with callbacks -->
<tbw-grid [editing]="{ editOn: 'dblclick', onBeforeEditClose: myCallback }" />

Enable clipboard copy/paste. Requires selection to be enabled.

Requires feature import:

import '@toolbox-web/grid-angular/features/clipboard';
<tbw-grid [selection]="'range'" [clipboard]="true" />

Enable right-click context menu.

Requires feature import:

import '@toolbox-web/grid-angular/features/context-menu';
<tbw-grid [contextMenu]="true" />

Enable multi-column sorting.

Multi-sort allows users to sort by multiple columns simultaneously. For basic single-column sorting, columns with sortable: true work without this plugin.

Requires feature import:

import '@toolbox-web/grid-angular/features/multi-sort';
<!-- Enable multi-column sorting -->
<tbw-grid [multiSort]="true" />
<!-- Limit to single column (uses plugin but restricts to 1 column) -->
<tbw-grid [multiSort]="'single'" />
<!-- Full config -->
<tbw-grid [multiSort]="{ maxSortColumns: 3 }" />

Enable column filtering.

Requires feature import:

import '@toolbox-web/grid-angular/features/filtering';
<tbw-grid [filtering]="true" />
<tbw-grid [filtering]="{ debounceMs: 200 }" />

Enable column drag-to-reorder.

Requires feature import:

import '@toolbox-web/grid-angular/features/reorder-columns';
<tbw-grid [reorderColumns]="true" />

Enable column visibility toggle panel.

Requires feature import:

import '@toolbox-web/grid-angular/features/visibility';
<tbw-grid [visibility]="true" />

Enable pinned/sticky columns. Columns are pinned via the sticky column property.

Requires feature import:

import '@toolbox-web/grid-angular/features/pinned-columns';
<tbw-grid [pinnedColumns]="true" [columns]="[
{ field: 'id', pinned: 'left' },
{ field: 'name' },
{ field: 'actions', pinned: 'right' }
]" />

Enable multi-level column headers (column groups).

Requires feature import:

import '@toolbox-web/grid-angular/features/grouping-columns';
<tbw-grid [groupingColumns]="true" />

Enable horizontal column virtualization for wide grids.

Requires feature import:

import '@toolbox-web/grid-angular/features/column-virtualization';
<tbw-grid [columnVirtualization]="true" />

Enable row drag-and-drop within and across grids.

Requires feature import:

import '@toolbox-web/grid-angular/features/row-drag-drop';
<tbw-grid [rowDragDrop]="{ dropZone: 'employees', operation: 'move' }" />

Enable row grouping by field values.

Requires feature import:

import '@toolbox-web/grid-angular/features/grouping-rows';
<tbw-grid [groupingRows]="{ groupBy: ['department'] }" />

Enable pinned rows (aggregation/status bar).

Requires feature import:

import '@toolbox-web/grid-angular/features/pinned-rows';
<tbw-grid [pinnedRows]="{ bottom: [{ type: 'aggregation' }] }" />

Enable hierarchical tree view.

Requires feature import:

import '@toolbox-web/grid-angular/features/tree';
<tbw-grid [tree]="{ childrenField: 'children' }" />

Enable master-detail expandable rows.

Requires feature import:

import '@toolbox-web/grid-angular/features/master-detail';
<tbw-grid [masterDetail]="{ detailRenderer: detailFn }" />

Enable responsive card layout for narrow viewports.

Requires feature import:

import '@toolbox-web/grid-angular/features/responsive';
<tbw-grid [responsive]="{ breakpoint: 768 }" />

Enable undo/redo for cell edits. Requires editing to be enabled.

Requires feature import:

import '@toolbox-web/grid-angular/features/undo-redo';
<tbw-grid [editing]="'dblclick'" [undoRedo]="true" />

Enable CSV/JSON export functionality.

Requires feature import:

import '@toolbox-web/grid-angular/features/export';
<tbw-grid [export]="true" />
<tbw-grid [export]="{ filename: 'data.csv' }" />

Enable print functionality.

Requires feature import:

import '@toolbox-web/grid-angular/features/print';
<tbw-grid [print]="true" />

Enable pivot table functionality.

Requires feature import:

import '@toolbox-web/grid-angular/features/pivot';
<tbw-grid [pivot]="{ rowFields: ['category'], valueField: 'sales' }" />

Enable server-side data operations.

Requires feature import:

import '@toolbox-web/grid-angular/features/server-side';
<tbw-grid [serverSide]="{ dataSource: fetchDataFn }" />

<tbw-grid [tooltip]="true" />
<tbw-grid [tooltip]="{ header: true, cell: false }" />

<tbw-grid (cellClick)="onCellClick($event)">...</tbw-grid>

<tbw-grid (rowClick)="onRowClick($event)">...</tbw-grid>

<tbw-grid (cellActivate)="onCellActivate($event)">...</tbw-grid>

<tbw-grid (cellChange)="onCellChange($event)">...</tbw-grid>

<tbw-grid (cellCommit)="onCellCommit($event)">...</tbw-grid>
onCellCommit(event: CellCommitEvent) {
console.log(`Changed ${event.field} to ${event.value} in row ${event.rowIndex}`);
}

<tbw-grid (cellCancel)="onCellCancel($event)">...</tbw-grid>

<tbw-grid (editOpen)="onEditOpen($event)">...</tbw-grid>

<tbw-grid (beforeEditClose)="onBeforeEditClose($event)">...</tbw-grid>

<tbw-grid (editClose)="onEditClose($event)">...</tbw-grid>

<tbw-grid (dirtyChange)="onDirtyChange($event)">...</tbw-grid>

<tbw-grid (dataChange)="onDataChange($event)">...</tbw-grid>

<tbw-grid (rowCommit)="onRowCommit($event)">...</tbw-grid>

<tbw-grid (changedRowsReset)="onChangedRowsReset($event)">...</tbw-grid>

<tbw-grid (sortChange)="onSortChange($event)">...</tbw-grid>

<tbw-grid (filterChange)="onFilterChange($event)">...</tbw-grid>

<tbw-grid (columnResize)="onColumnResize($event)">...</tbw-grid>

<tbw-grid (columnResizeReset)="onColumnResizeReset($event)">...</tbw-grid>

<tbw-grid (columnMove)="onColumnMove($event)">...</tbw-grid>

<tbw-grid (columnVisibility)="onColumnVisibility($event)">...</tbw-grid>

<tbw-grid (columnStateChange)="onColumnStateChange($event)">...</tbw-grid>

<tbw-grid (selectionChange)="onSelectionChange($event)">...</tbw-grid>

<tbw-grid (rowMove)="onRowMove($event)">...</tbw-grid>

<tbw-grid (rowDragStart)="onRowDragStart($event)">...</tbw-grid>

<tbw-grid (groupToggle)="onGroupToggle($event)">...</tbw-grid>

<tbw-grid (groupExpand)="onGroupExpand($event)">...</tbw-grid>

<tbw-grid (groupCollapse)="onGroupCollapse($event)">...</tbw-grid>

<tbw-grid (treeExpand)="onTreeExpand($event)">...</tbw-grid>

<tbw-grid (detailExpand)="onDetailExpand($event)">...</tbw-grid>

<tbw-grid (responsiveChange)="onResponsiveChange($event)">...</tbw-grid>

<tbw-grid (contextMenuOpen)="onContextMenuOpen($event)">...</tbw-grid>

<tbw-grid (copy)="onCopy($event)">...</tbw-grid>

<tbw-grid (paste)="onPaste($event)">...</tbw-grid>

<tbw-grid (undo)="onUndo($event)">...</tbw-grid>

<tbw-grid (redo)="onRedo($event)">...</tbw-grid>

<tbw-grid (exportComplete)="onExportComplete($event)">...</tbw-grid>

<tbw-grid (printStart)="onPrintStart($event)">...</tbw-grid>

<tbw-grid (printComplete)="onPrintComplete($event)">...</tbw-grid>

Emitted (rAF-batched) when the grid’s viewport is scrolled vertically.

For server-side pagination of large datasets prefer ServerSidePlugin — this event is the lower-level primitive for custom load-more triggers, deferring heavy cell content, dismissing overlays, etc.

Named tbwScroll (not scroll) to avoid collision with the native DOM scroll event that bubbles from focusable internals.

<tbw-grid (tbwScroll)="onScroll($event)">...</tbw-grid>

Emitted once at the end of every render-scheduler flush, after all plugin afterRender hooks have run and ready() has resolved.

Use this to act on the rendered DOM after a programmatic mutation (e.g. focus the first input of a freshly added row in full-grid edit mode) without setTimeout or double-requestAnimationFrame hacks. The render event fires on every flush — including scroll-driven virtual-window updates — so prefer subscribing once and unsubscribing (or gating on detail.phase >= RenderPhase.ROWS) when you only care about a specific mutation.

<tbw-grid (render)="onRender($event)">...</tbw-grid>

A callback method that is invoked immediately after the default change detector has checked the directive’s data-bound properties for the first time, and before any of the view or content children have been checked. It is invoked only once when the directive is instantiated.

ngOnInit(): void

A callback method that is invoked immediately after Angular has completed initialization of all of the directive’s content. It is invoked only once when the directive is instantiated.

ngAfterContentInit(): void

A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.

ngOnDestroy(): void

AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://toolboxjs.com/llms-full.txt