Integrating AdapTable Vue
Summary
- To use AdapTable Vue, you need to:
- Import AdapTable Vue components from
@adaptabletools/adaptable-vue3-aggrid - Provide and configure 3 Vue components:
AdaptableProvider,AdaptableUIandAdaptableAgGridVue
- Import AdapTable Vue components from
Creating applications that use AdapTable Vue is straightforward.
Find Out More
- Fastest start: the Vue support template (CodeSandbox)
- Integration instructions: Integrating AdapTable
Hint
- Clone the support template if you want a running app immediately
- The rest of this page explains what that code is doing
Vue Components
There are 3 key Vue components that need to be provided:
| Component | Purpose |
|---|---|
AdaptableProvider | manages Adaptable State and orchestrates the AdapTable and AG Grid components |
AdaptableUI | renders AdapTable's UI Components including the Dashboard |
AdaptableAgGridVue | thin AdapTable wrapper around the AG Grid Vue component |
Minimum working example
<script setup lang="ts">
import {LicenseManager, themeQuartz, type GridOptions, type Module} from 'ag-grid-enterprise';
import {AllEnterpriseModule} from 'ag-grid-enterprise';
import {AgChartsEnterpriseModule} from 'ag-charts-enterprise';
import {
AdaptableProvider,
AdaptableUI,
AdaptableAgGridVue,
type AdaptableOptions,
type AdaptableReadyInfo,
type InitialState,
} from '@adaptabletools/adaptable-vue3-aggrid';
import '@adaptabletools/adaptable-vue3-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,
};
const onAdaptableReady = ({adaptableApi, agGridApi}: AdaptableReadyInfo) => {
adaptableApi.quickSearchApi.runQuickSearch('toy');
agGridApi.autoSizeAllColumns();
};
</script>
<template>
<AdaptableProvider
:gridOptions="gridOptions"
:modules="agGridModules"
:adaptableOptions="adaptableOptions"
@onAdaptableReady="onAdaptableReady"
>
<AdaptableUI style="flex: none" />
<AdaptableAgGridVue style="flex: 1" />
</AdaptableProvider>
</template>Developer Guide
Defining the 3 Vue Components
import {
AdaptableProvider,
AdaptableUI,
AdaptableAgGridVue,
type AdaptableOptions,
type AdaptableReadyInfo,
type InitialState,
} from '@adaptabletools/adaptable-vue3-aggrid';Import the 3 AdapTable Vue components (and any types you need) from @adaptabletools/adaptable-vue3-aggrid:
AdaptableProviderAdaptableUIAdaptableAgGridVue
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.
Pass the array to AdaptableProvider 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
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 (including the correct cell data types)
- initial data (if not lazy loading)
- AG Grid events
- additional, required properties
Caution
- Always set the appropriate
cellDataTypeproperty in ColumnDefs for every Column, to enable AdapTable to use the correct Filters and related properties - Many ColDef properties are ignored by AdapTable and replaced by Layout props - see full details in Guide to Layouts and ColDefs
Note
- AG Grid Enterprise also requires its own license key
- Set it with
LicenseManager.setLicenseKeyfromag-grid-enterprise(the support template shows this)
import '@adaptabletools/adaptable-vue3-aggrid/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
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 you purchase AdapTable
- a User Name to identify the current user
- the
initialStatecreated 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
Often added next: Entitlements, Plugins, and remote State persistence
<template>
<AdaptableProvider
:gridOptions="gridOptions"
:modules="agGridModules"
:adaptableOptions="adaptableOptions"
>
<AdaptableUI style="flex: none" />
<AdaptableAgGridVue style="flex: 1" />
</AdaptableProvider>
</template>Render AdaptableProvider with these 3 mandatory props:
gridOptions— GridOptions object created in Step 3modules— AG Grid Modules array created in Step 2adaptableOptions— Adaptable Options created in Step 6
Inside the Provider, render:
<AdaptableUI />for AdapTable's UI, notably the Dashboard<AdaptableAgGridVue />— not<AgGridVue />directly
Caution
- Render
<AdaptableAgGridVue />and not the<AgGridVue />component directly AdaptableAgGridVueshould not receive agridOptionsormodulesprop; pass those toAdaptableProvider
const onAdaptableReady = ({adaptableApi, agGridApi}: AdaptableReadyInfo) => {
adaptableApi.quickSearchApi.runQuickSearch('toy');
agGridApi.autoSizeAllColumns();
};Add @onAdaptableReady on AdaptableProvider.
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:
adaptableApiwhich gives access to the Adaptable APIagGridApiwhich gives access to AG Grid's Api
Find Out More
See the Integration section in Getting Started for related articles 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
FAQ
Should I render <AgGridVue /> myself?
No. Render <AdaptableAgGridVue /> inside AdaptableProvider, and pass gridOptions and modules to the Provider — not to the grid component.
Find Out More
Common first-run questions (modules, cell data types, browsers, watermarks) are on the Getting Started FAQ.