API Reference — Overview

GridCraft exposes a small, focused public API. Everything you need is exported from the single entry point @gridcraft/angular. All exports are individually tree-shakeable thanks to Angular's standalone component model — unused features add zero bytes to your bundle.

Installation & import

Add the component to any standalone Angular component or NgModule by importing it directly. No module registration, no forRoot — just import what you use.

import {
  GridcraftComponent,
  GridColumn,
  GridConfig,
  GridDataSource,
  FetchParams,
  FetchResult,
} from '@gridcraft/angular';

@Component({
  selector: 'app-my-grid',
  standalone: true,
  imports: [GridcraftComponent],
  template: `
    <gridcraft
      [columns]="columns"
      [dataSource]="dataSource"
      [config]="config"
    />
  `,
})
export class MyGridComponent {
  // ...
}

Standalone & tree-shaking

Because GridcraftComponent is a standalone Angular component, Angular's compiler only bundles the directives, pipes, and services that are actually referenced in your template. Features like export (GridExportService), column persistence, and sub-grid nesting are only included when configured.

Full public API

The following symbols are exported from @gridcraft/angular:

SymbolKindDescription
GridcraftComponentComponentRoot grid component. Add to your template as <gridcraft>.
GridColumnInterfaceColumn definition object. Pass an array to the [columns] input.
GridConfigInterfaceTop-level configuration object. Pass to the [config] input.
GridDataSourceInterfaceData source contract. Implement fetchRows() and pass to [dataSource].
FetchParamsInterfaceParameters passed to fetchRows(): offset, limit, sorts, filters, page.
FetchResultInterfaceReturn shape of fetchRows(): rows array and totalCount.
ScrollModeType'infinite' | 'paging' | 'virtual-paging' — controls pagination strategy.
FilterModeType'row' | 'popup' — controls where filter controls are rendered.
FilterStateTypeActive filter map: Record<columnKey, FilterValue | null>.
SortConfigInterfaceA single sort entry: { key: string; dir: 'asc' | 'desc' }.
GroupingConfigInterfaceRow grouping options: groupBy, showCount, startCollapsed, fetchGroups.
GcGroupRowInterfaceSentinel object inserted into the display array for each group header row.
isGcGroupRowFunctionType guard: isGcGroupRow(row) returns true for group header sentinels.
RowExpandConfigInterfaceRow expansion settings: expandMode, estimatedHeight, canExpand, subGrid.
SubGridConfigInterfaceNested grid configuration for expand rows: columns, dataSource, config.
CellContextInterfaceTemplate context for cellTemplate: row, value, column, rowIndex.
ExpandContextInterfaceTemplate context for #gcExpandRow: row, rowIndex.
SummaryContextInterfaceTemplate context for subHeaderTemplate and footerTemplate: column.
GridStateSnapshotInterfaceSerialisable snapshot of interactive state (sorts, filters, columns, page). Use with grid.getState() / setState() / [initialState].
GridTransactionInterfaceBatch mutation for live updates: { add?, update?, remove?, addIndex? }. Pass to applyTransaction() or stream via [liveSource].
TransactionResultInterfaceReturn value of applyTransaction(): { added, updated, removed } arrays with per-cell change info.
LiveConfigInterfaceLive-update tuning knobs nested in GridConfig.live: flashCells, flashDuration, flushInterval, maxRows, etc.
GridThemeTokensTypePartial<Record<GcThemeVar, string | number>> — runtime per-grid CSS variable overrides. Pass to [themeTokens]. Numbers auto-suffixed with px/ms.
ContextMenuConfigInterfaceRight-click context menu configuration in GridConfig.contextMenu. Supports static arrays or resolver functions for cellItems and headerItems.
ContextMenuItemInterfaceOne menu item: label, icon, action, children (submenu), disabled, hidden, separator.
ContextMenuContextInterfacePassed to item resolvers and action callbacks: type ('cell'|'header'), row, column, value, selectedRows.
RowDragConfigInterfaceRow drag-reorder config in GridConfig.rowDrag: managed (auto-reorder in state), position, canDrag predicate.
RowDragEventInterfaceEmitted by (rowDragEnd) after a drop: { row, fromIndex, toIndex, rows }.
CellEditEventInterfaceEmitted by (cellEditCommit) after an inline edit is committed: { row, oldRow, colKey, oldValue, newValue }.
GRID_MESSAGESConstantPre-built UI text for 12 locales (en, ar, fr, de, es, pt, fa, ur, tr, zh, ja, ru). Pass to config.messages or GridDirectionService.setMessages().
RTL_LOCALESConstantSet<string> of RTL locale codes: 'ar', 'fa', 'ur'. Use alongside GRID_MESSAGES when switching app language.
GridDirectionServiceService Root-level reactive service. Methods: setDir(), setTheme(), setMessages(), patchMessages(). Changes apply to all grids without an explicit per-grid override. Import it from @gridcraft/angular/core in anything that runs before your first route — see Bundle Size.
provideGridDefaultsFunction Provider factory for app-wide GridConfig defaults. Call once in ApplicationConfig.providers. Per-grid [config] always wins. Import it from @gridcraft/angular/core: app.config.ts loads before any route, and the main barrel would pull the whole grid into your first download.
GcThemeVar · GridThemeTokens · ThemeSeedTypes The theming vocabulary: every themeable --gc-* variable name, a complete token set, and the compact seed one can be derived from. Pass a GridThemeTokens literal to the grid's themeTokens input, or set the variables in CSS — see Theming.
tokensToStyleObjectFunctionTurns a GridThemeTokens literal into an inline-style object, appending each token's unit (px / ms) to numeric values. What the grid's themeTokens input uses internally; exported for when you bind [style] yourself.

Quick-reference: inputs & outputs

The three inputs on <gridcraft> cover all use cases. All grid behaviour is configured through the [config] object — no extra directives or attributes needed.

<!-- All three inputs are independent -->
<gridcraft
  [columns]="columns"          <!-- GridColumn<T>[]  — REQUIRED -->
  [dataSource]="dataSource"    <!-- GridDataSource<T> — omit for static data -->
  [config]="config"            <!-- GridConfig<T>     — all optional, has safe defaults -->

  (sortChange)="onSort($event)"         <!-- SortConfig[] -->
  (selectionChange)="onSelect($event)"  <!-- T[] -->
  (filterChange)="onFilter($event)"     <!-- FilterState -->
  (rowClick)="onRowClick($event)"       <!-- { row: T; index: number } -->
  (rowsLoaded)="onLoad($event)"         <!-- T[] -->
/>

Next steps

Dive into the individual reference pages:

  • GridConfig — all configuration options with defaults
  • GridColumn — column definition properties
  • Data Source — server data contract and grouping protocol