DataGrid Feature Guide

API reference

This page maps the DataGrid public API to the current package exports. Inputs, outputs, templates, exported types, services, and adapters listed here are available from @angular-bootstrap/ngbootstrap today.

Overview

The DataGrid public surface is spread across the main component export, the filtering and column model exports, the template directives, data operation helpers, and the editing/export services. This page documents only members exported by the package entry point today.

Basic import example

import {
          Datagrid,
          ColumnDef,
          NgbCellTemplate,
          NgbEditorTemplate,
          NgbFilterTemplate,
          NgbRowDetailTemplate,
          NgbDatagridEditService,
          NgbDatagridDefaultEditService,
          NgbDatagridTrackByFn,
          NgbDataGridExportOptions,
          NgbExportService,
          PdfExportAdapter,
          ExcelExportAdapter,
          JsPdfAdapter,
          BrowserExcelExportAdapter
        } from '@angular-bootstrap/ngbootstrap';

How the API is organized

  • The component export includes the main grid plus selection and table option types declared in the component file.
  • ColumnDef and the filtering descriptors are exported from their model files.
  • Template directives are exported separately and matched by field name.
  • NgbExportService, PdfExportAdapter, ExcelExportAdapter, JsPdfAdapter, and BrowserExcelExportAdapter are public package exports used to wire built-in or custom export behavior.

API Information

Datagrid · Inputs
PropertyTypeDefaultDescription
[columns]ColumnDef<T>[][]Column definitions. Declarative `ngb-grid-column` content takes precedence when both are present.
[data]T[][]Row data bound into the grid.
[loading]booleanfalseShows a loading overlay and sets the grid busy state.
[total]number | nullnullTotal row count for server-side paging when `data` contains only the current page.
[enableSorting]booleanfalseTurns on header sorting for columns marked `sortable`.
[enableFiltering]booleanfalseLegacy compatibility flag that enables filtering features.
[filterable]boolean | 'row' | 'menu' | 'multi' | 'none'falsePreferred filtering mode API. `true` maps to row filtering.
[enableGlobalFilter]booleanfalseShows the global filter input in the toolbar.
[filterMode]'row' | 'menu' | 'multi' | 'none''row'Fallback mode used when `filterable` is not explicit.
[filter]NgbCompositeFilterDescriptor | nullnullControlled filter descriptor for descriptor-based filtering.
[filterOperators]Partial<Record<ColumnType, NgbFilterOperator[]>>undefinedOverrides the allowed operators by column type.
[filterManual]booleanfalseEmits `filterChange` without applying the descriptor locally.
[externalFiltering]booleanfalseTreats `data` as already filtered while still rendering the filter UI.
[dataOperations]boolean | NgbDataGridProcessOptions<T>falseUses the reusable local operation helper for sort, filter, page, and aggregate processing.
[groupable]boolean | NgbDataGridGroupingSettingsfalseEnables the group panel, group drag handles, and grouped row rendering. Use `showFooter` for grouped footer rows, `stickyHeaders` for pinned grouped headers, and `stickyFooters` for pinned grouped footers.
[group]NgbDataGridGroupDescriptor[][]Controlled group descriptors for one or more grouped fields.
[groupedData]NgbDataGridGroupResult<T>[] | nullnullOptional processed grouped result input for manual or server-owned grouping flows.
[state]NgbDataGridState | nullnullControlled state for page, page size, skip, sort descriptors, group descriptors, filter descriptor, and global search.
[enablePagination]booleanfalseRenders the built-in footer pager and page-size selector.
[pageSize]number10Current page size used by the built-in pagination logic.
[pageSizeOptions]number[][5, 10, 25, 50]Page-size options shown in the footer selector.
[enableEdit]booleanfalseShows row edit actions and enables the edit form.
[enableDelete]booleanfalseShows row delete actions.
[enableAdd]booleanfalseShows the add-row button and renders the add form row.
[newRowDefaults]Partial<T> | (() => Partial<T>) | nullnullProvides initial values for the add-row form.
[strictEmail]booleanfalseSwitches email validation to the stricter custom validator.
[editOnRowClick]booleanfalseStarts editing when a non-interactive area of a row is clicked.
[singleExpand]booleanfalseLimits detail-row expansion to one row at a time.
[selectionMode]'none' | 'single' | 'multiple''none'Enables row selection.
[selectionBehavior]'row' | 'checkbox' | 'both''row'Controls whether rows, checkboxes, or both can toggle selection.
[selectionKeyMode]'desktop' | 'mobile''desktop'Desktop mode enables Ctrl/Cmd and Shift range selection behavior.
[selectAllEnabled]booleantrueEnables the current-page select-all checkbox when multi-select is active.
[selectionA11yLabels]NgbSelectionLabels{}Overrides accessible labels for selection controls.
[selectionDisabledFn](row: T, index: number) => booleanundefinedDisables selection for specific rows.
[rowReorderable]booleanfalseEnables row drag handles and row reordering.
[stickyRows]booleanfalseShows the sticky-row utility column and keeps pinned rows at the top.
[stickyHeader]booleanfalseEnables the sticky header when scrolling is active.
[stickyFooter]booleanfalseEnables the sticky footer when scrolling is active.
[stickyRowHeight]number40Height used to stack multiple sticky rows.
[stickyHeaderHeight]number40Header offset used for stacked sticky rows.
[stickyFooterHeight]number56Footer height used by the sticky-footer styling.
[scrollable]booleantrueControls whether the body wrapper becomes vertically scrollable.
[tableOptions]NgbTableOptions{}Applies Bootstrap table classes plus caption, responsive wrapper, and sticky flags.
[theme]'bootstrap' | 'material' | 'tailwind''bootstrap'Adds theme-specific CSS variables and button/table styling.
[responsive]boolean | NgbDataGridResponsiveOptionsfalseEnables the small-screen stacked layout.
[highlightedIndex]Array<{ row: unknown; columnKey?: unknown }>[]Declares highlighted rows or row/cell pairs.
[highlightRowKey]string | ((row, rowIndex) => unknown) | nullnullComputes the row key used by `highlightedIndex`.
[highlightColKey]string | ((column, columnIndex) => unknown) | nullnullComputes the column key used by `highlightedIndex`.
[searchHighlightTerm]string''Highlights matching text fragments inside visible cells.
[searchHighlightFields]string[] | nullnullLimits search highlighting to specific column fields.
[trackBy]NgbDatagridTrackByFn<T>undefinedProvides a stable row identifier value for tracking, selection, sticky rows, and editing.
[editService]NgbDatagridEditService<T>default serviceOverrides the built-in edit service for immutable or stateful editing workflows.
[exportOptions]NgbDataGridExportOptions{ enabled: false, ... }Enables PDF and/or Excel export and configures the export mode.
[dataProviderAll]() => Observable<T[]> | Promise<T[]> | T[]undefinedRequired when export pages mode is `all`.
[dataProviderSelection]() => T[]undefinedRequired when export pages mode is `selection`.
[columnReorderable]booleanfalseEnables drag-drop reordering for columns.
[resizable]booleanfalseEnables drag resizing for explicit-width columns.
Datagrid · Outputs
PropertyTypeDefaultDescription
(rowAdd){ newRow: T }-Emits after a new row passes validation and the add flow saves.
(rowEdit){ row: T; index: number }-Emits when a row enters edit mode.
(rowSave){ original: T; updated: T; index: number }-Emits after the edit form is validated and saved.
(rowCancel){ row: T; index: number }-Emits when edit mode is cancelled.
(rowDelete){ row: T; index: number }-Emits after a row delete action runs.
(groupChange)NgbDataGridGroupChange-Emits the current ordered group descriptors after panel or API grouping changes.
(sortChange){ active: string | null; direction: 'asc' | 'desc' | '' }-Emits the current sort state after the header cycle changes.
(filterChange)NgbCompositeFilterDescriptor-Preferred filtering event for descriptor-driven filtering.
(filtersChange){ global: string; columns: Record<string, string> }-Legacy compatibility event for global and column filter text state.
(pageChange){ page: number; pageSize: number }-Emits when the built-in pager changes page or page size.
(dataStateChange)NgbDataGridState-Emits complete sort, filter, page, page size, skip, and global filter state.
(selectionChange){ selected: T[]; lastAction: { row: T; index: number; selected: boolean } | null }-Emits the selected rows and the last selection action.
(rowReorder){ row: T; fromIndex: number; toIndex: number; data: T[] }-Emits after row drag-drop reorders the data.
(columnReorder)NgbColumnReorderEvent<ColumnDef<T>>-Emits after column drag-drop reorders visible columns.
Datagrid · Template directives
PropertyTypeDefaultDescription
<ng-template ngbCell="field">directive-Overrides read-mode rendering for a column and receives `value`, `row`, `col`, and `index`.
<ng-template ngbEditor="field">directive-Overrides the edit control for a column and receives `control`, `row`, `col`, `form`, `index`, and `isNew`.
<ng-template ngbFilter="field">directive-Overrides the row-filter UI for a column and receives filter context helpers.
<ng-template ngbFilterMenu="field">directive-Overrides the menu-filter UI for a column.
<ng-template ngbGlobalFilter>directive-Overrides the toolbar global filter input and receives the global control.
<ng-template ngbDatagridGroupHeaderTemplate>directive-Overrides the main grouped header row and receives field, value, items, level, count, and aggregates.
<ng-template ngbDatagridGroupHeaderColumnTemplate="field">directive-Renders inside a grouped header cell for a specific column.
<ng-template ngbDatagridGroupFooterTemplate="field">directive-Renders inside a grouped footer cell for a specific column when grouped footers are enabled.
<ng-template ngbRowDetail>directive-Renders expandable detail content for each row and receives the row plus the paged index.
<ng-template ngbExportButton>directive-Overrides the export toolbar buttons and receives a trigger function for `pdf` or `excel`.
<ngb-grid-column ...>directive-Declarative column definition with the same inputs as `ColumnDef`.
Datagrid · Exported types
PropertyTypeDefaultDescription
ColumnDef<T>interface-Column metadata for the grid, including sorting, filtering, editing, sticky, locked, width, and validation settings.
NgbFilterDescriptorinterface-Single filter rule with `field`, `operator`, optional `value`, and `ignoreCase`.
NgbCompositeFilterDescriptorinterface-Root filter tree with `logic` and nested filter descriptors.
NgbFilterStateinterface-Convenience state shape with `global` plus a descriptor root.
NgbFilterOperatortype-Supported operators such as `contains`, `eq`, `gt`, `isnull`, and `isempty`.
NgbFilterabletype-Filtering mode input type: `boolean`, `row`, `menu`, `multi`, or `none`.
NgbTableOptionsinterface-Bootstrap table presentation options plus caption, responsive wrapper, and sticky flags.
NgbSelectionMode / Behavior / KeyModetype-Selection configuration types used by the row selection API.
NgbSelectionLabelsinterface-Optional accessible labels for select-all and per-row selection controls.
NgbDataGridExportOptionsinterface-Export configuration for PDF/Excel, page source, file names, and adapter-specific options.
NgbDataGridGroupDescriptorinterface-Grouped field descriptor with `field`, optional ascending/descending `dir`, and optional per-group `aggregates`.
NgbDataGridGroupingSettingsinterface-Grouping configuration object with `showFooter`, `stickyHeaders`, and `stickyFooters`.
NgbDataGridGroupChangeinterface-Event payload emitted by `(groupChange)` with the active descriptor list.
NgbDataGridGroupResult<T>interface-Nested local or provided grouping result with field, value, level, count, optional aggregate results, and child items.
NgbDataGridStateinterface-Unified data-operation state with page, page index, skip, page size, sort, group, filter, and global filter.
NgbDataGridDataResult<T>interface-Processed rows plus total count, optional grouped data, and aggregate results.
NgbDataGridProcessOptions<T>interface-Options for local data operations, global filter fields, columns, aggregate descriptors, provided grouped data, and paging.
NgbDataGridAggregateDescriptorinterface-Aggregate field and function descriptor for count, sum, avg, average, min, or max.
NgbDataGridAggregateTypetype-Supported aggregate names used by descriptors and grouped aggregate results.
NgbDataGridThemetype-Grid-scoped theme token name used by the DataGrid and theme picker.
NgbDataGridResponsiveOptionsinterface-Responsive mode settings. The current implementation only checks `enabled`.
NgbDatagridEditService<T>interface-Edit workflow contract used by the grid for create, update, delete, save, and cancel handling.
NgbDatagridTrackByFn<T>type-Track-by callback that returns a stable row identifier value.
NgbGridChartConfig<T>interface-Configuration for the Grid to Chart composite widget.
NgbDataChartConfiginterface-Standalone chart renderer configuration.
NgbAdvancedSearchField / Ruleinterfaces-Reusable advanced search field and rule configuration.
NgbSearchHighlightFieldinterface-Field metadata for the search highlight widget.
Datagrid · Services and adapters
PropertyTypeDefaultDescription
NgbDatagridDefaultEditService<T>class-Default immutable edit service that tracks original rows and removes unsaved new rows on cancel.
NgbExportServiceclass-Delegates export calls to an injected PDF or Excel adapter.
PdfExportAdapter / ExcelExportAdapterabstract class-Adapter contracts that power PDF and Excel export.
JsPdfAdapterclass-Built-in dependency-free PDF adapter that creates a simple browser-generated table PDF.
BrowserExcelExportAdapterclass-Built-in dependency-free Excel adapter that creates a browser-generated workbook.
ngbApplyDataGridOperationsfunction-Processes local arrays with filtering, global search, sorting, paging, and aggregates.
ngbGroupDatafunction-Groups local arrays by one or more field descriptors and returns nested group metadata.
ngbCalculateDataGridAggregatesfunction-Calculates local aggregate values for configured fields.
NgbAdvancedSearchComponentstandalone component-Reusable advanced search builder that emits DataGrid filter descriptors.
NgbSearchHighlightComponentstandalone component-Reusable search-highlight controls for DataGrid or any external list/grid.
NgbGridChartComponentstandalone component-Composite grid and Chart.js-backed chart widget.
NgbDataChartComponentstandalone component-Standalone chart renderer.
NgbDataSparklineComponentstandalone component-Inline sparkline renderer for cells or standalone layouts.
NgbDatagridThemePickerComponentstandalone component-Grid theme picker that emits NgbDataGridTheme values.

Usage notes

  • The package still exposes some legacy filtering inputs and outputs for compatibility, but new examples should prefer the descriptor-based API.
  • The responsive options type includes breakpoint fields that are not currently honored by the component logic. The docs intentionally describe only the implemented behavior.

Common issues

  • Do not document or depend on internal directives or helpers unless they are exported from the package public API.

This project is not affiliated with ng-bootstrap or ngx-bootstrap. Those projects focus mainly on Bootstrap components for Angular. ngbootstrap focuses on Angular UI for data-heavy apps, especially Data Grid, Angular-native Form Builder, drag and drop workflows, documentation examples, and performance-focused Angular patterns.