Integrating AdapTable React

View as Markdown

Summary

  • To use AdapTable React, you need to import { Adaptable } from @adaptabletools/adaptable-react-aggrid
  • You also need to provide 3 components: Adaptable.Provider, Adaptable.UI & Adaptable.AgGridReact
  • You can either leverage the adaptable-setup AI Agent Skill or integrate manually

Integration Options

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

Coding agent + adaptable-setup


Install the Agent Skills once, then ask your agent to run the 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.

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 React project with rows fetched from https://api.example.com/trades

Manual integration

The sections below walk through the React components and a minimum working example.

React Components

There are 3 key React components that need to be provided:

ComponentPurpose
Adaptable.Providermanages Adaptable State and orchestrates the AdapTable and AG Grid components
Adaptable.UIrenders AdapTable's UI Components including the Dashboard
Adaptable.AgGridReactthin AdapTable wrapper around the AG Grid React component
Developer Guide

Defining the 3 React Components

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

export const agGridModules: Module[] = [
  AllEnterpriseModule.with(AgChartsEnterpriseModule),
];
1
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.

Pass the array to <Adaptable.Provider /> in Step 7.

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,
};
2
Create an 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 (including the correct cell data types)
  • initial data (if not lazy loading)
  • AG Grid events
  • additional, required properties

Caution

Note

  • AG Grid Enterprise also requires its own license key
  • Set it with LicenseManager.setLicenseKey from ag-grid-enterprise (the support template shows this)
import {
  Adaptable,
  type AdaptableApi,
  type AdaptableOptions,
  type AdaptableReadyInfo,
  type InitialState,
} from '@adaptabletools/adaptable-react-aggrid';
3
Import AdapTable

Import Adaptable and the types you need from @adaptabletools/adaptable-react-aggrid.

import '@adaptabletools/adaptable-react-aggrid/index.css';
4
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
const initialState: InitialState = {
  Dashboard: {
    PinnedToolbars: ['Layout', 'Export'],
  },
  Layout: {
    CurrentLayout: 'Cars',
    Layouts: [
      {
        Name: 'Cars',
        TableColumns: ['id', 'make', 'model', 'price'],
      },
    ],
  },
};
5
Supply 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,
};
6
Create an Adaptable Options object

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 you purchase AdapTable
  • a User Name to identify the current user
  • the initialState created in Step 5

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

<Adaptable.Provider
  gridOptions={gridOptions}
  modules={agGridModules}
  adaptableOptions={adaptableOptions}>
  <Adaptable.UI style={{flex: 'none'}} />
  <div style={{flex: 1}}>
    <Adaptable.AgGridReact />
  </div>
</Adaptable.Provider>
7
Render the three AdapTable React components

Render Adaptable.Provider with these 3 mandatory props:

  • gridOptions — GridOptions object created in Step 2
  • modules — AG Grid Modules array created in Step 1
  • adaptableOptions — Adaptable Options created in Step 6

Inside the Provider, render:

  • <Adaptable.UI /> for AdapTable's UI and Dashboard
  • <Adaptable.AgGridReact /> — not <AgGridReact /> directly

Caution

  • Adaptable.AgGridReact should not receive a gridOptions or modules prop; pass those to Adaptable.Provider
<Adaptable.Provider
  gridOptions={gridOptions}
  modules={agGridModules}
  adaptableOptions={adaptableOptions}
  onAdaptableReady={({adaptableApi, agGridApi}: AdaptableReadyInfo) => {
    adaptableApi.quickSearchApi.runQuickSearch('toy');
    agGridApi.autoSizeAllColumns();
  }}>
  <Adaptable.UI style={{flex: 'none'}} />
  <div style={{flex: 1}}>
    <Adaptable.AgGridReact />
  </div>
</Adaptable.Provider>
8
Subscribe to Adaptable Ready Event (optional)

Add onAdaptableReady on Adaptable.Provider.

This Event is fired when AdapTable is initialised, and should be used to perform any setup related actions required.

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

  • adaptableApi which gives access to the Adaptable API
  • agGridApi which gives access to AG Grid's Api

Minimum Working Example

import {useRef} from 'react';
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 InitialState,
} from '@adaptabletools/adaptable-react-aggrid';
import '@adaptabletools/adaptable-react-aggrid/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,
};

export const AdaptableGrid = () => {
  const adaptableApiRef = useRef<AdaptableApi | null>(null);

  const onAdaptableReady = ({adaptableApi, agGridApi}: AdaptableReadyInfo) => {
    adaptableApiRef.current = adaptableApi;
    adaptableApi.quickSearchApi.runQuickSearch('toy');
    agGridApi.autoSizeAllColumns();
  };

  return (
    <Adaptable.Provider
      gridOptions={gridOptions}
      modules={agGridModules}
      adaptableOptions={adaptableOptions}
      onAdaptableReady={onAdaptableReady}>
      <Adaptable.UI style={{flex: 'none'}} />
      <div style={{flex: 1}}>
        <Adaptable.AgGridReact />
      </div>
    </Adaptable.Provider>
  );
};

FAQ

Why do I have a 'multiple versions of React' message? AdapTable uses React internally and has a minimum required version. If you are using other imports / libraries which require a lower version of React than this, then you will get this message, as npm will install a separate version of React for AdapTable (this happens if you have node_modules/@adaptabletools/adaptable/node_modules/react present). You can also figure out why React is installed by running the npm ls react command.

Should I use your Redux store or my own? Use your own. Although the general advice is one store per application, the best practice when you are using an external component (like AdapTable) is to have separate stores. You can subscribe to AdapTable's store, but in practice we strongly recommend using the Adaptable State Changed Event instead — it gives you the same information in a more structured and safe way.

Find Out More

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

AdapTable Resources