# Migrating from AG Grid

> Map AG Grid grid options, column definitions, API calls, events and filter models to their Birch UI Grid equivalents.

Birch UI Grid uses many of the same concepts as AG Grid: column definitions, a row id callback, transactions, column state and modules. Most migrations are a rename of options plus a simplification of callbacks, because Birch UI callbacks receive your row object directly instead of a `params` wrapper.

This guide maps the options you are most likely to use. Features marked Pro need [Grid Pro](https://docs.birchui.com/grid-pro/overview.md), Birch UI's equivalent of AG Grid Enterprise.

To convert a codebase automatically, run the [migration tool](https://docs.birchui.com/getting-started/migration-tool.md), which applies these mappings and lists what is left to do by hand.

## Before and after

An AG Grid setup in plain JavaScript:

```ts title="orders-grid.ts (AG Grid)"
import { createGrid, ModuleRegistry, AllCommunityModule } from 'ag-grid-community';

ModuleRegistry.registerModules([AllCommunityModule]);

const api = createGrid(document.querySelector('#orders')!, {
  columnDefs: [
    { field: 'id', headerName: 'Order', width: 120, pinned: 'left' },
    { field: 'customer', headerName: 'Customer', flex: 1, filter: 'agTextColumnFilter' },
    {
      field: 'total',
      headerName: 'Total',
      type: 'numericColumn',
      valueFormatter: (params) => usd.format(params.value),
    },
  ],
  defaultColDef: { sortable: true, resizable: true, floatingFilter: true },
  rowData: orders,
  getRowId: (params) => params.data.id,
  rowSelection: { mode: 'multiRow' },
  pagination: true,
  paginationPageSize: 50,
  onCellValueChanged: (event) => saveOrder(event.data),
});
```

The same grid in Birch UI:

```ts title="orders-grid.ts (Birch UI)"
import { createGrid } from '@birchui/core';

const grid = createGrid<Order>(document.querySelector('#orders')!, {
  columns: [
    { field: 'id', header: 'Order', width: 120, pinned: 'left' },
    { field: 'customer', header: 'Customer', flex: 1, filter: 'text' },
    {
      field: 'total',
      header: 'Total',
      type: 'number',
      format: (value) => usd.format(Number(value)),
    },
  ],
  defaultColumn: { sortable: true, resizable: true },
  floatingFilters: true,
  rows: orders,
  getRowId: (order) => order.id,
  rowSelection: 'multiple',
  pagination: { pageSize: 50 },
});

grid.on('cellValueChanged', ({ row }) => saveOrder(row));
```

The main differences:

- `columnDefs` becomes `columns`, `rowData` becomes `rows`, `headerName` becomes `header`.
- Callbacks receive your row (and value) directly: `getRowId: (order) => order.id` instead of `(params) => params.data.id`.
- Events are subscribed with `grid.on(name, handler)`, which returns an unsubscribe function. Framework components expose them as props or outputs.
- There is no global module registry. Pass Grid Pro modules per grid with `modules: [...]`.
- Floating filters are switched on for the whole grid with `floatingFilters: true`.

## Grid options

| AG Grid | Birch UI | Notes |
| --- | --- | --- |
| `columnDefs` | `columns` | |
| `rowData` | `rows` | Or `api.setRows(rows)` |
| `getRowId: (params) => params.data.id` | `getRowId: (row, index) => row.id` | |
| `defaultColDef` | `defaultColumn` | |
| `rowHeight` | `rowHeight` | A number |
| `getRowHeight` | `rowHeight` as a function | Receives the display row |
| `headerHeight` | `headerHeight` | |
| `defaultColDef.floatingFilter` | `floatingFilters: true` | One switch for the grid |
| `quickFilterText` | `quickFilter` | Or `api.setQuickFilter(text)`. Searches every column, hidden ones included, and every word must match |
| `rowSelection: 'single'` or `{ mode: 'singleRow' }` | `rowSelection: 'single'` | |
| `rowSelection: 'multiple'` or `{ mode: 'multiRow' }` | `rowSelection: 'multiple'` | |
| `checkboxSelection` on a column, or `rowSelection.checkboxes` | `checkboxSelection: true` | Adds a pinned checkbox column; needs `rowSelection` |
| `pagination` and `paginationPageSize` | `pagination: { pageSize: 50 }` | `pagination: true` uses 100 rows per page |
| `multiSortKey`, `alwaysMultiSort` | `multiSort` | Shift-click adds a sort column |
| `className="ag-theme-quartz-dark"` or `theme` | `theme: 'dark'` | `'light'`, `'dark'` or `'auto'` |
| `rowClass`, `getRowClass` | `rowClass: (row) => className` | |
| `overlayNoRowsTemplate` | `emptyMessage` | Plain text |
| `rowBuffer` | `overscanRows` | Column overscan: `overscanColumns` |
| `ModuleRegistry.registerModules([...])` | `modules: [...]` | Per grid, not global |
| `LicenseManager.setLicenseKey(key)` | `setLicenseKey(key)` from `@birchui/license` | Or the `licenseKey` option |
| `groupDisplayType`, `autoGroupColumnDef` | `groupColumn` | Pro |
| `groupDefaultExpanded` | `groupDefaultExpanded` | Pro |
| `rowGroupPanelShow: 'always'` | `groupPanel: true` | Pro |
| `grandTotalRow`, `groupTotalRow` | `groupTotals: true` | Pro |
| `treeData` and `getDataPath` | `treeData` and `getDataPath` | Pro. Or `getParentId` for flat parent references |
| `pivotMode: true` | `pivot: { enabled: true, rows, columns, values }` | Pro |
| `cellSelection` or `enableRangeSelection` | `rangeSelection: true` | Pro |
| `enableFillHandle` | `fillHandle: true` | Pro |
| `masterDetail` and `detailCellRenderer` | `masterDetail: { render(row, container) }` | Pro |
| `statusBar: { statusPanels }` | `statusBar: true` or `{ rowCount, selectedCount, aggregates }` | Pro |

## Column definitions

| AG Grid | Birch UI | Notes |
| --- | --- | --- |
| `field` | `field` | |
| `colId` | `id` | Defaults to `field` |
| `headerName` | `header` | |
| `headerTooltip` | `headerTooltip` | |
| `width`, `minWidth`, `maxWidth`, `flex` | same names | |
| `pinned: 'left'` | `pinned: 'left'` | Free in Birch UI |
| `hide` | `hidden` | |
| `sortable`, `resizable` | same names | |
| `suppressMovable: true` | `reorderable: false` | |
| `filter: 'agTextColumnFilter'` | `filter: 'text'` | |
| `filter: 'agNumberColumnFilter'` | `filter: 'number'` | |
| `filter: 'agDateColumnFilter'` | `filter: 'date'` | |
| `filter: 'agSetColumnFilter'` | `filter: 'set'` | Free in Birch UI |
| `filter: true` | `filter: true` | Picks the filter from the column `type`, or `set` when the column has `options` |
| `cellDataType: 'number'`, `type: 'numericColumn'` | `type: 'number'` | Right-aligned by default. Types: `text`, `number`, `date`, `boolean` |
| `editable` | `editable` | Boolean or `(ctx) => boolean` |
| `cellEditor: 'agTextCellEditor'` | `editor: 'text'` | |
| `cellEditor: 'agNumberCellEditor'` | `editor: 'number'` | |
| `cellEditor: 'agDateCellEditor'` | `editor: 'date'` | |
| `cellEditor: 'agCheckboxCellEditor'` | `editor: 'checkbox'` | |
| `cellEditor: 'agSelectCellEditor'`, `cellEditorParams: { values }` | `editor: 'select'`, `options: [...]` | Options can be `{ value, label }` |
| Custom `cellEditor` component | `editor: (params) => CellEditor` | A factory returning `{ element, getValue, focus }` |
| `valueGetter: (params) => params.data.price * params.data.quantity` | `valueGetter: (row) => row.price * row.quantity` | |
| `valueSetter: (params) => { ...; return true }` | `valueSetter: (row, value) => { ... }` | No return value |
| `valueParser: (params) => Number(params.newValue)` | `valueParser: (input, row) => Number(input)` | |
| `valueFormatter: (params) => ...` | `format: (value, row) => string` | |
| `cellRenderer` | `cell: (ctx) => string \| Node` | Return text or a DOM node |
| `cellClass` | `cellClass` | String or `(ctx) => string` |
| `cellClassRules` | `cellClass` as a function | |
| `headerClass` | `headerClass` | |
| `comparator: (a, b, nodeA, nodeB)` | `comparator: (a, b, rowA, rowB)` | Receives rows, not nodes |
| `aggFunc: 'sum'` | `aggFunc: 'sum'` | Pro. Also `'distinct'` or a function |
| `rowGroup`, `rowGroupIndex` | same names | Pro |
| `pivot`, `pivotIndex` | same names | Pro |
| `context`, custom properties | `meta` | Free-form data for your own code |

## Grid API

| AG Grid | Birch UI |
| --- | --- |
| `api.setGridOption('rowData', rows)` | `api.setRows(rows)` or `api.update({ rows })`. Selection is kept for rows whose id still exists and dropped for the rest |
| `api.setGridOption('columnDefs', cols)` | `api.setColumns(cols)` |
| `api.setGridOption(key, value)` | `api.update({ [key]: value })` |
| `api.applyTransaction({ add, update, remove })` | `api.applyTransaction({ add, update, remove })`. `remove` also accepts row ids |
| `api.getRowNode(id)` | `api.getRowById(id)`, which returns your row object |
| `api.getDisplayedRowAtIndex(i)` | `api.getDisplayRow(i)` for an index on the current page, or `api.getAllDisplayRows()[i]` across pages |
| `api.getDisplayedRowCount()` | `api.getAllDisplayRows().length` |
| `api.forEachNodeAfterFilterAndSort(fn)` | `api.getAllDisplayRows().forEach(fn)`; each display row's `data` is your row |
| `api.forEachNode(fn)` | `api.getRows().forEach(fn)` |
| `api.getSelectedRows()` | `api.getSelectedRows()` |
| `api.selectAll()`, `api.deselectAll()` | same names |
| `node.setSelected(true)` | `api.setRowSelected(id, true)` |
| `api.getColumnState()` | `api.getColumnState()` |
| `api.applyColumnState({ state })` | `api.applyColumnState(state)` |
| `api.setColumnsVisible([id], false)` | `api.setColumnHidden(id, true)` |
| `api.setColumnsPinned([id], 'left')` | `api.setColumnPinned(id, 'left')` |
| `api.moveColumns([id], index)` | `api.moveColumn(id, index)` |
| `api.setColumnWidths([{ key, newWidth }])` | `api.setColumnWidth(id, width)` |
| `api.autoSizeColumns([id])`, `api.autoSizeAllColumns()` | `api.autosizeColumn(id)`, `api.autosizeColumns()` |
| `api.applyColumnState({ state: [{ colId, sort }] })` for sorting | `api.setSort([{ colId, dir: 'asc' }])` |
| `api.setFilterModel(model)` | `api.setFilterModel(model)`. The model shape differs; see below |
| `api.setColumnFilterModel(id, model)` | `api.setFilter(id, model)` |
| `api.setGridOption('quickFilterText', text)` | `api.setQuickFilter(text)` |
| `api.ensureIndexVisible(i, 'middle')` | `api.scrollToRow(i, 'center')` |
| `api.ensureColumnVisible(id)` | `api.scrollToColumn(id)` |
| `api.setFocusedCell(i, id)` | `api.focusCell(i, id)` |
| `api.getFocusedCell()` | `api.getFocusedCell()` |
| `api.startEditingCell({ rowIndex, colKey })` | `api.startEdit(rowIndex, colId)` |
| `api.stopEditing(cancel)` | `api.stopEdit(cancel)` |
| `api.refreshCells()` | `api.refresh()` |
| `api.redrawRows()` | `api.redraw()` |
| `api.expandAll()`, `api.collapseAll()` | same names |
| `node.setExpanded(true)` | `api.setExpanded(rowId, true)`, which also takes an array of ids |
| `node.expanded` | `api.isExpanded(rowId)`; pass `{ ignoreExpandAll: true }` to ignore `expandAll()` and `collapseAll()` |
| `api.setRowGroupColumns(cols)` | `api.setGroupBy?.(cols)` (Pro) |
| `api.getRowGroupColumns()` | `api.getGroupBy?.()` (Pro) |
| Expanding groups to a depth | `api.expandToLevel?.(level)` (Pro) |
| `api.setGridOption('pivotMode', true)` with `setPivotColumns` and `setValueColumns` | `api.setPivot?.({ enabled: true, rows, columns, values })` (Pro) |
| `api.getPivotResultColumns()` | `api.getPivotResult?.()` (Pro) |
| Aggregates shown in the status bar | `api.getColumnAggregate?.(colId, 'sum')` (Pro) |
| `api.paginationGoToPage(n)` | `api.setPage(n)` |
| `api.paginationGetCurrentPage()` | `api.getPage()` |
| `api.paginationGetTotalPages()` | `api.getPageCount()` |
| `api.getDataAsCsv(params)` | `api.exportCsv(options)`, which returns a string |
| `api.exportDataAsCsv(params)` | `api.downloadCsv(options)` |
| `api.exportDataAsExcel(params)` | `await api.exportExcel?.({ fileName, sheetName, onlySelected, allRows })` (Pro, with `ExcelModule`). Exports the filtered and sorted rows of every page, not just the current one, and leaves collapsed groups collapsed; `allRows: true` also writes the rows inside collapsed groups as hidden outline rows |
| `api.getDataAsExcel(params)` | `await api.getExcelBlob?.(options)` (Pro, with `ExcelModule`) |
| No equivalent: import an `.xlsx` file into the grid | `await api.importExcel?.(file)` (Pro, with `ExcelModule`) |
| `api.addEventListener(name, fn)` | `api.on(name, fn)`, which returns an unsubscribe function |
| `api.isDestroyed()`, `api.destroy()` | `api.destroy()` |

Grid Pro modules add their methods to `GridApi`: the Excel methods come from `ExcelModule`, and the grouping, pivot and aggregate methods from the analytics modules. TypeScript therefore declares them as optional. Call them with `?.`, as above, or check that they exist first. The Excel methods return promises.

See the full [GridApi reference](https://docs.birchui.com/api/core.md#gridapi).

## Events

| AG Grid | Birch UI | Payload |
| --- | --- | --- |
| `onGridReady` | `ready` | `{ api }` |
| `onCellClicked` | `cellClick` | `{ row, displayRow, rowIndex, colId, value, event }` |
| `onCellDoubleClicked` | `cellDoubleClick` | same as `cellClick` |
| `onCellKeyDown` | `cellKeyDown` | same as `cellClick` |
| `onCellValueChanged` | `cellValueChanged` | `{ row, rowIndex, colId, oldValue, newValue, source }` |
| `onRowClicked` | `rowClick` | `{ row, displayRow, rowIndex, event }` |
| `onSelectionChanged` | `selectionChanged` | `{ selected }`, the selected rows |
| `onSortChanged` | `sortChanged` | `{ sort }`. Also fires for changes made with `setSort` or `update({ sort })` |
| `onFilterChanged` | `filterChanged` | `{ filterModel, quickFilter }`. Also fires for changes made through the API or `update()` |
| `onColumnResized` | `columnResized` | `{ colId, width }` |
| `onColumnMoved` | `columnMoved` | `{ colId, toIndex }` |
| `onColumnPinned` | `columnPinned` | `{ colId, pinned }` |
| `onColumnVisible` | `columnVisible` | `{ colId, hidden }` |
| Any column event, to persist state | `columnStateChanged` | `{ state }` |
| `onModelUpdated` | `modelUpdated` | `{ rowCount, displayRowCount }` |
| `onCellFocused` | `focusChanged` | `{ cell }` |
| `onBodyScroll` | `viewportScroll` | `{ top, left }` |
| `onPaginationChanged` | `pageChanged` | `{ page, pageCount }` |
| `onRowGroupOpened` | `rowExpanded` | `{ rowId, expanded }` |
| `onCellEditingStarted` | `editStart` | `{ rowIndex, colId }` |
| `onCellEditingStopped` | `editStop` | `{ rowIndex, colId, cancelled }` |

`cellValueChanged.source` tells you whether the change came from an `edit`, a clipboard `paste`, the `fill` handle or the `api`. See the [events reference](https://docs.birchui.com/grid/events.md).

## Filter models

AG Grid stores a `filterType` and a `type` per column. Birch UI stores a `type` and an `op`:

```ts title="AG Grid"
api.setFilterModel({
  customer: { filterType: 'text', type: 'contains', filter: 'traders' },
  total: { filterType: 'number', type: 'inRange', filter: 100, filterTo: 500 },
  placedAt: { filterType: 'date', type: 'lessThan', dateFrom: '2026-11-01' },
  region: { filterType: 'set', values: ['EMEA', 'APAC'] },
});
```

```ts title="Birch UI"
grid.setFilterModel({
  customer: { type: 'text', op: 'contains', value: 'traders' },
  total: { type: 'number', op: 'between', value: 100, valueTo: 500 },
  placedAt: { type: 'date', op: 'before', value: '2026-11-01' },
  region: { type: 'set', values: ['EMEA', 'APAC'] },
});
```

| AG Grid `type` | Birch UI `op` |
| --- | --- |
| `contains`, `notContains`, `equals`, `notEqual`, `startsWith`, `endsWith` (text) | `contains`, `notContains`, `equals`, `notEquals`, `startsWith`, `endsWith` |
| `equals`, `notEqual` (number) | `eq`, `ne` |
| `lessThan`, `lessThanOrEqual`, `greaterThan`, `greaterThanOrEqual` (number) | `lt`, `lte`, `gt`, `gte` |
| `inRange` (number or date) | `between` with `value` and `valueTo` |
| `equals`, `lessThan`, `greaterThan` (date) | `eq`, `before`, `after` |
| `blank`, `notBlank` | `blank`, `notBlank` |

AG Grid allows two conditions per column joined with `AND` or `OR`. Birch UI has one condition per column; for compound rules, use a `custom` filter with a `test` function:

```ts
grid.setFilter('total', {
  type: 'custom',
  test: (value) => Number(value) < 50 || Number(value) > 5000,
});
```

Floating filters also accept expressions such as `>100` or `10..20` in number columns. See [Filtering](https://docs.birchui.com/grid/filtering.md).

## Cell renderers

AG Grid cell renderers are components or functions that receive `params`. A Birch UI `cell` function receives a context object and returns a string or a DOM node:

```ts
const statusColumn: ColumnDef<Order> = {
  field: 'status',
  header: 'Status',
  cell: ({ value }) => {
    const badge = document.createElement('span');
    badge.className = `order-status order-status-${String(value)}`;
    badge.textContent = String(value);
    return badge;
  },
};
```

The context contains `row`, `value`, `formatted` (the result of `format`), `column`, `rowIndex`, `displayRow` and `api`. Return a string for plain text; it is inserted as text, not HTML. See [Columns](https://docs.birchui.com/grid/columns.md).

## Modules

AG Grid registers modules globally. Birch UI passes them per grid, so two grids on one page can use different feature sets:

```ts
import { createGrid } from '@birchui/core';
import { RowGroupingModule, AggregationModule, ExcelModule } from '@birchui/grid-pro';

createGrid(container, {
  columns,
  rows,
  modules: [RowGroupingModule, AggregationModule, ExcelModule],
  groupBy: ['region'],
});
```

`AllProModules` contains every Grid Pro module. See [Modules](https://docs.birchui.com/grid/modules.md).

## Licensing differences

| | AG Grid Enterprise | Birch UI Grid Pro |
| --- | --- | --- |
| Purchase | Perpetual license with one year of updates | One-time purchase with updates forever, majors included |
| Who needs a seat | Every front-end developer on the project | Only developers who write code against Birch UI; build-only colleagues need none |
| Without a key | Watermark and console messages | Watermark on non-local hosts and one console warning; every feature works |
| Key check | Offline | Offline, no network calls |
| Apps and end users | Depends on the license type | Unlimited in every tier |

Read [Licensing and activation](https://docs.birchui.com/getting-started/licensing.md) for the details.

## Features without a direct equivalent

Plan around these when you migrate:

- **Server-side row model and infinite row model.** Birch UI works with rows held in memory and virtualizes rendering. Load data in pages yourself and call `applyTransaction` or `setRows`. The grid is built to handle a million rows in memory.
- **Integrated charts and sparklines.** Birch UI Charts (`@birchui/charts`, a separate license) covers both: `chartFromRange(values, headers)` builds chart options from a Grid Pro range for `createChart`, and `sparklineSVG(values)` returns SVG markup for sparklines. See the [Charts overview](https://docs.birchui.com/charts/overview.md).
- **Side bar and tool panels.** Not available. Build your own panel with `getColumns`, `setColumnHidden` and `applyColumnState`.
- **Row dragging.** Not available.
- **Framework components as cell renderers.** `cell` returns a string or a DOM node.

## Migration checklist

1. Install `@birchui/core` (plus `@birchui/grid-pro` if you use Enterprise features) and your [framework adapter](https://docs.birchui.com/getting-started/installation.md#framework-adapters).
2. Rename grid options and column properties using the tables above.
3. Rewrite `params` callbacks to take the row or value directly.
4. Replace `api.addEventListener` and `on*` grid options with `grid.on(...)` or the adapter's event props.
5. Convert saved filter models and column state.
6. Move Enterprise modules into `modules: [...]` on each grid.
7. Replace the AG Grid theme class with `theme` and the `--lq-*` CSS variables. See [Theming](https://docs.birchui.com/grid/theming.md).
8. Set your key with `setLicenseKey`.
