#Getting Started
Install the package:
npm install @adaptabletools/datagrid-angular@canaryVersion 0.9 is published on the canary dist-tag until its stable release: @canary installs the latest canary.
The package needs Angular 22. @angular/cdk is a peer dependency, like @angular/forms: npm and pnpm install it with the package.
Add the stylesheet to the global styles of your app, in angular.json:
"styles": ["@adaptabletools/datagrid-angular/index.css", "src/styles.css"]The grid adds about 3.5 MB to the initial bundle of your app (630 kB compressed, with the stylesheet). The expression editor is not part of that: it is loaded the first time it is opened. A new Angular app fails its production build when the initial bundle is over 1 MB, so do one of the following:
-
Raise the
initialbudget, inangular.json(architect.build.configurations.production.budgets):{ "type": "initial", "maximumWarning": "4MB", "maximumError": "5MB" } -
Or show the grid on a route that is loaded lazily. The grid is then a chunk of its own, loaded the first time the route is visited, and the initial bundle stays as it was:
export const routes: Routes = [ { path: 'grid', loadComponent: () => import('./grid/grid.component').then((m) => m.GridComponent), }, ];
#Your first grid
In order to render your first grid, you need 3 important things:
- a
dataprop (an array, a promise, or a fetch function) - a
defaultStateobject that includes the available columns and an active view. - a
primaryKeyfor your data
import { Component } from '@angular/core';
import {
AdaptableProvider,
AdaptableUI,
type AdaptableUserState,
type AdaptableColumnConfig,
} from '@adaptabletools/datagrid-angular';
1. grab your data - array, promise or fetch function
import { data } from './basic.data';
2a. define the available columns
const availableColumns: Record<string, AdaptableColumnConfig> = {
firstName: { field: 'firstName', dataType: 'text' },
country: { field: 'country', dataType: 'text' },
salary: {
field: 'salary',
dataType: 'number',
aggregatable: true,
renderValue: ({ value }) =>
value == null ? null : `$${(value as number).toLocaleString('en-US')}`,
},
};
const defaultState: AdaptableUserState = {
globalEntities: {
columnDefaults: { width: 140 },
// an object where the keys are the column ids
// and the values are the column configurations
// { firstName: { field: 'firstName', dataType: 'text' }, ... }
availableColumns,
},
dashboard: {
top: { widgets: [{ id: 'views', type: 'view' }] },
},
view: {
2b. define your views
currentViewId: 'flat',
views: [
{
// all columns are shown by default
id: 'flat',
label: 'All developers',
},
{
id: 'second view',
label: 'Specific column order',
columnOrder: ['firstName', 'preferredLanguage', 'salary', 'country'],
},
],
},
};
@Component({
selector: 'demo-root',
imports: [AdaptableProvider, AdaptableUI],
template: `
3. configure your primary key
<adaptable-provider primaryKey="id"
adaptableId="docs-basic"
[data]="data"
[defaultState]="defaultState"
>
<adaptable-ui />
</adaptable-provider>
`,
})
export default class BasicDemo {
protected readonly data = data;
protected readonly defaultState = defaultState;
}You need to configure the primaryKey of your data, so Adaptable will know to properly handle and reference your row data.
The components are standalone: list them in the imports of your component (AdaptableProvider, AdaptableUI, AdaptableWorkspace) and write their elements in its template: <adaptable-provider>, <adaptable-ui />, <adaptable-workspace />. What goes inside <adaptable-provider> is written in the same template.
Inputs have the same names as the React props: [data], [defaultState], primaryKey="id". The controlled state is a model, [(state)], and onReady is the output (ready).
Two views over the same data — switch them from the picker in the dashboard.
Interact with a view, switch to another, then switch back — you’ll find it as you left it.
Three things to notice:
availableColumnsdeclares every column the grid knows about — label, data type, width, renderers and any other column properties. Views then pick and arrange them.viewsare first-class: thecolumnOrder, sorting and grouping you see is just state. Users can change it at runtime, and you can persist the result.<adaptable-workspace />renders the full product — the datagrid, the settings panel, dashboard, view picker. When you need custom UI layouts, compose<adaptable-workspace>,<adaptable-data-grid>,<adaptable-dashboard>and friends yourself — see UI.
State passed via [defaultState] is uncontrolled — the grid owns it after mount.
Bind [(state)] instead when you want to own it.
#Next steps
- Loading data — client vs server mode, TDGP, TanStack Query
- Theming — tokens, dark mode, accent presets