Integrating AdapTable with AG Grid
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
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.
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:
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.initimplementation
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>These 2 div elements should be named (ideally in this order):
- adaptable - contains the AdapTable instance
- grid - contains the AG Grid instance
Note
- It is possible to name the Divs containing AG Grid and AdapTable differently (in place of the default values: grid and adaptable)
- In this case, provide these names in
ContainerOptions- see Providing bespoke AdapTable and AG Grid div Ids for more details (also if using a Shadow DOM)
import '@adaptabletools/adaptable/index.css';index.css contains core styles (and supports both light and dark themes)
Hint
- AdapTable's styles use the
adaptableCSS 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';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),
];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
ClientSideRowModelModuleis 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,
};Define and populate a standard AG Grid GridOptions object.
Provide all required AG Grid related information including:
- AG Grid theme (
themeQuartzin 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
cellDataTypeproperty 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.setLicenseKeyfromag-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'],
},
],
},
};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:
const adaptableOptions: AdaptableOptions = {
licenseKey: '<ADAPTABLE_LICENSE_KEY_HERE>',
primaryKey: 'id',
userName: 'Demo User',
adaptableId: 'Basic Setup',
initialState,
};Adaptable Options defines exactly how AdapTable should work.
Every instance needs:
- a Primary Key — a unique column
- an Adaptable Id which uniquely identifies the Grid
- the License Key provided when purchasing AdapTable
- a User Name to identify the current user
- the
initialStatecreated above
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
Often added next: Entitlements, Plugins, and remote State persistence
const agGridConfig: AgGridConfig = {
gridOptions,
modules: agGridModules,
};
const adaptableApi: AdaptableApi = await Adaptable.init(
adaptableOptions,
agGridConfig
);The static async AdapTable constructor receives 2 objects:
- the Adaptable Options created in Step 7
- an
AgGridConfigobject which contains two properties:gridOptions— the Grid Options object created in Step 5modules— 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();
}
);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:
adaptableApiwhich gives access to the Adaptable APIagGridApiwhich gives access to AG Grid's Api
Caution
If you are using TypeScript then you must use version 5.8.3 or higher
Find Out More
See the related articles in this documentation for more detailed instructions on:
- Choosing a Primary Key
- Setting the Adaptable Id
- Providing a User Name
- Creating Adaptable Context
- Configuring the Adaptable State Key
- Providing Initial Adaptable State
- Managing Remote State Persistence
- Supplying the AdapTable License Key
- Layouts vs ColDefs
- Setting Cell Data Types
- Listening to Adaptable Ready Event
- Testing AdapTable
- Selecting or Creating an AdapTable Theme
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
- TypeScript support template
- Vanilla JavaScript support template
- All the demos on this site can be run in TypeScript by clicking the TypeScript button in the top corner
- They can also be forked to Sandbox and run independently (with full code visible)