Integrating AdapTable with AG Grid

View as Markdown

Summary

  • Integrating a TypeScript (framework-agnostic) AdapTable instance with AG Grid is straightforward
  • You can either leverage the adaptable-setup AI Agent Skill or integrate manually
  • Also 3 Framework wrappers available: React, Angular and Vue

This page shows how to create a "vanilla" AdapTable instance — one that does not use a UI-framework wrapper.

Like all the demos on this site, the example is in TypeScript (used by most developers using AdapTable).

Integration Options

Creating applications that use AdapTable vanilla is straightforward.
There are two ways to integrate AdapTable:
Recommended

adaptable-setup AI Skill


Install Agent Skills , then run adaptable-setup skill.

It pairs AG Grid with AdapTable, wires containers and Initial State, and validates setup for your installed version.

Step by step

Manual integration


Clone a support template (CodeSandbox) for a running app, or follow the minimum working example on this page.

Best when you want to learn the wiring, review every line, or work without a coding agent.

Pure JavaScript: vanilla JS support template.

Agent Integration

Simply leverage the adaptable-setup AI skill, providing all relevant information:

adaptable-setupAI Skill

add AdapTable to this AG Grid app


set up AdapTable in a new TypeScript project with rows fetched from https://api.example.com/trades

Manual Integration

Minimum Working Example

This is a complete first AdapTable instance containing:

  • two containers
  • CSS
  • AG Grid Modules
  • unique primary key
  • one Layout
  • Adaptable.init implementation
import {
  LicenseManager,
  themeQuartz,
  type GridOptions,
  type Module,
} from 'ag-grid-enterprise';
import {AllEnterpriseModule} from 'ag-grid-enterprise';
import {AgChartsEnterpriseModule} from 'ag-charts-enterprise';
import {
  Adaptable,
  type AdaptableApi,
  type AdaptableOptions,
  type AdaptableReadyInfo,
  type AgGridConfig,
  type InitialState,
} from '@adaptabletools/adaptable';
import '@adaptabletools/adaptable/index.css';

LicenseManager.setLicenseKey('<AG_GRID_LICENSE_KEY_HERE>');

const agGridModules: Module[] = [
  AllEnterpriseModule.with(AgChartsEnterpriseModule),
];

const gridOptions: GridOptions = {
  theme: themeQuartz,
  columnDefs: [
    {headerName: 'Id', field: 'id', cellDataType: 'number'},
    {headerName: 'Make', field: 'make', filter: true, cellDataType: 'text'},
    {headerName: 'Model', field: 'model', editable: true, cellDataType: 'text'},
    {headerName: 'Price', field: 'price', cellDataType: 'number'},
  ],
  rowData: [
    {id: 1, make: 'Toyota', model: 'Yaris', price: 40000},
    {id: 2, make: 'Toyota', model: 'Corolla', price: 28000},
    {id: 3, make: 'Ford', model: 'Mondeo', price: 32000},
  ],
  cellSelection: true,
  sideBar: true,
};

const initialState: InitialState = {
  Dashboard: {
    PinnedToolbars: ['Layout', 'Export'],
  },
  Layout: {
    CurrentLayout: 'Cars',
    Layouts: [
      {
        Name: 'Cars',
        TableColumns: ['id', 'make', 'model', 'price'],
      },
    ],
  },
};

const adaptableOptions: AdaptableOptions = {
  licenseKey: '<ADAPTABLE_LICENSE_KEY_HERE>',
  primaryKey: 'id',
  userName: 'Demo User',
  adaptableId: 'Basic Setup',
  initialState,
};

const agGridConfig: AgGridConfig = {
  gridOptions,
  modules: agGridModules,
};

const adaptableApi: AdaptableApi = await Adaptable.init(
  adaptableOptions,
  agGridConfig
);

adaptableApi.eventApi.on(
  'AdaptableReady',
  ({adaptableApi, agGridApi}: AdaptableReadyInfo) => {
    adaptableApi.quickSearchApi.runQuickSearch('toy');
    agGridApi.autoSizeAllColumns();
  }
);

The HTML needs the two default containers:

<body>
  <div id="adaptable"></div>
  <div id="grid" style="height:500px"></div>
</body>
Developer Guide

Detailed Guide to Creating a non-Framework AdapTable Instance (TypeScript)

These are the steps involved in creating a new (vanilla) AdapTable instance:

<body>
  <div id="adaptable"></div>
  <div id="grid" style="height:500px"></div>
</body>
1
Create Two Div Elements in your HTML

These 2 div elements should be named (ideally in this order):

  • adaptable - contains the AdapTable instance
  • grid - contains the AG Grid instance

Note

import '@adaptabletools/adaptable/index.css';
2
Import AdapTable Styles via index.css

index.css contains core styles (and supports both light and dark themes)

Hint

  • AdapTable's styles use the adaptable CSS layer - so you can access that to control specificity
  • If your app is using Tailwind, we recommend using this CSS layer order: @layer theme, base, components, adaptable, utilities
  • See AdapTable Theming Guide for full details on choosing and extending AdapTable Themes
import {
  Adaptable,
  type AdaptableApi,
  type AdaptableOptions,
  type AdaptableReadyInfo,
  type AgGridConfig,
  type InitialState,
} from '@adaptabletools/adaptable';
3
Import AdapTable's types

Import the main Adaptable object and any required types from @adaptabletools/adaptable.

Everything is a named export.

import {AllEnterpriseModule, type Module} from 'ag-grid-enterprise';
import {AgChartsEnterpriseModule} from 'ag-charts-enterprise';

export const agGridModules: Module[] = [
  AllEnterpriseModule.with(AgChartsEnterpriseModule),
];
4
Import and Define AG Grid Enterprise Modules

Import the AG Grid Enterprise Modules.

The support templates use the Enterprise bundle together with AG Charts. That covers AG Grid Charts and AdapTable Sparkline Columns.

Note

  • To register only the modules your feature set needs, see AG Grid Modules
  • In AG Grid 36 the Client-Side Row Model is part of the grid core, so ClientSideRowModelModule is not required
import {themeQuartz, type GridOptions} from 'ag-grid-enterprise';

const gridOptions: GridOptions = {
  theme: themeQuartz,
  columnDefs: [
    {headerName: 'Id', field: 'id', cellDataType: 'number'},
    {headerName: 'Make', field: 'make', filter: true, cellDataType: 'text'},
    {headerName: 'Model', field: 'model', editable: true, cellDataType: 'text'},
    {headerName: 'Price', field: 'price', cellDataType: 'number'},
  ],
  rowData: [
    {id: 1, make: 'Toyota', model: 'Yaris', price: 40000},
    {id: 2, make: 'Toyota', model: 'Corolla', price: 28000},
    {id: 3, make: 'Ford', model: 'Mondeo', price: 32000},
  ],
  cellSelection: true,
  sideBar: true,
};
5
Create AG Grid GridOptions object

Define and populate a standard AG Grid GridOptions object.

Provide all required AG Grid related information including:

  • AG Grid theme (themeQuartz in this example)
  • column schema via columnDefs (including the correct cell data types)
  • initial data (if not lazy loading)
  • AG Grid events
  • any additional, required properties

Caution

  • Many ColDef properties are ignored by AdapTable and replaced by Layout props - see full details in Guide to Layouts and ColDefs
  • Do not instantiate AG Grid; AdapTable will do that itself, together with any required wiring up of objects

Hint

  • Always set the appropriate cellDataType property in ColumnDefs for each Column that is defined
  • This will enable AdapTable to use the correct set of Filters and related properties - see Setting Cell Data Types for more information

Note

  • AG Grid Enterprise also requires its own license key
  • Set it with LicenseManager.setLicenseKey from ag-grid-enterprise (the support template shows this)
const initialState: InitialState = {
  Dashboard: {
    PinnedToolbars: ['Layout', 'Export'],
  },
  Layout: {
    CurrentLayout: 'Cars',
    Layouts: [
      {
        Name: 'Cars',
        TableColumns: ['id', 'make', 'model', 'price'],
      },
    ],
  },
};
6
Provide Initial Adaptable State

Add the Initial Adaptable State that is required to ship AdapTable with the objects you require for initial use.

This will later get merged into Adaptable State, together with any changes made by the run-time user.

It must include a Layouts section, containing at least one Layout (unless using Default Layouts).

In this example we:

  • Pin the Layout and Export Toolbars on the Dashboard
  • Create a Layout "Cars" whose ColumnIds match the ColDef field values
const adaptableOptions: AdaptableOptions = {
  licenseKey: '<ADAPTABLE_LICENSE_KEY_HERE>',
  primaryKey: 'id',
  userName: 'Demo User',
  adaptableId: 'Basic Setup',
  initialState,
};
7
Create an Adaptable Options object

Adaptable Options defines exactly how AdapTable should work.

Every instance needs:

Hint

Adaptable Options supports TypeScript Generics which ensures a better developer experience by providing the row data type

Important

If the licenseKey property is not present, AdapTable will display a watermark and run with reduced functionality

Note

const agGridConfig: AgGridConfig = {
  gridOptions,
  modules: agGridModules,
};

const adaptableApi: AdaptableApi = await Adaptable.init(
  adaptableOptions,
  agGridConfig
);
8
Instantiate AdapTable using the static async constructor

The static async AdapTable constructor receives 2 objects:

  • the Adaptable Options created in Step 7
  • an AgGridConfig object which contains two properties:
    • gridOptions — the Grid Options object created in Step 5
    • modules — the AG Grid Modules defined in Step 4

It returns (via a Promise) an Adaptable API object - which gives run time access to all AdapTable functionality.

adaptableApi.eventApi.on(
  'AdaptableReady',
  ({adaptableApi, agGridApi}: AdaptableReadyInfo) => {
    adaptableApi.quickSearchApi.runQuickSearch('toy');
    agGridApi.autoSizeAllColumns();
  }
);
9
Subscribe to Adaptable Ready Event (optional)

Add listener to Adaptable Ready Event which fires when AdapTable is initialised.

This should be used to perform any required setup-related actions.

The AdaptableReadyInfo object provided by the Event contains two key objects:

Caution

If you are using TypeScript then you must use version 5.8.3 or higher

Accessing AdapTable at Run-Time

The Adaptable API has many hundreds of methods to allow full, programmatic access to all AdapTable functionality and state at run-time.

It also includes an eventApi section for listening to Adaptable Events.

Hint

The same API is how you write tests: wait for Adaptable Ready, then assert through the API. See Testing AdapTable.

Destroying AdapTable

It is possible to programmatically destroy - and clean up - an AdapTable session.

This is done by using the destroy function, available in the root of Adaptable API.

Note

  • This function is only needed for the vanilla version of AdapTable
  • All 3 Framework wrappers handle unmount and cleanup as part of the application lifecycle

The function performs 2 important actions:

  • unmounts the Adaptable component
  • destroys the AG Grid instance.

FAQ

Why do I see an error message saying There is no DIV with id=[Name] so cannot render Adaptable? You have likely supplied a bespoke value for the adaptableContainer property in Container Options but not provided a Div with the same name.

I am using Stencil and cannot see AdapTable? Stencil uses a shadow DOM, so you need to specify the agGridContainer and adaptableContainer in adaptableOptions.containerOptions as elements, not as strings. If you have scoped: true then use:

this.el.shadowRoot.querySelector(...)

to retrieve references to your vendor grid & adaptable container elements.

If you have scoped: false you should use:

this.el.querySelector(...)

Find Out More

Common first-run questions (modules, cell data types, browsers, watermarks) are on the Getting Started FAQ.

AdapTable Resources