GridApi object returned when creating the grid or via the api property in event callbacks.
Overview
The Grid API is your main interface for controlling the grid after itβs initialized:Accessing the API
At Grid Creation
In Event Handlers
In Framework Components
Core Methods
Grid Lifecycle
Destroy the grid and release resources. Required when using vanilla JavaScript.
Check if the grid has been destroyed.
Grid Options
Get the current value of a grid option.
setGridOption(key, value)
<Key extends ManagedGridOptionKey>(key: Key, value: GridOptions[Key]) => void
Update a single grid option.
Update multiple grid options at once (recommended over multiple
setGridOption calls).Row Data Methods
Transactions
Add, remove, or update rows efficiently.
applyTransactionAsync(transaction, callback?)
(transaction: RowDataTransaction, callback?: (res: RowNodeTransaction) => void) => void
Queue a transaction for async execution. Grid batches multiple async transactions for efficiency.
Execute all queued async transactions immediately.
Row Access
Iterate through all row nodes (ignoring filtering/sorting).
forEachNodeAfterFilterAndSort(callback)
(callback: (rowNode: IRowNode, index: number) => void) => void
Iterate through displayed rows (after filtering and sorting).
Get a specific row node by its ID.
Get the total number of displayed rows.
Column Methods
Column Definitions
Get current column definitions.
Get the column definition for a specific column.
Column Visibility
Show or hide columns.
Column Sizing
Size columns to fit the available grid width.
autoSizeColumns(keys, skipHeader?)
(keys: ColKey[] | ISizeColumnsToContentParams, skipHeader?: boolean) => void
Auto-size specific columns based on content.
Auto-size all columns.
Column State
Get current column state (width, position, sort, etc).
Restore column state.
Selection Methods
Select all rows.
Deselect all rows.
Get selected row nodes.
Get selected row data.
Filtering Methods
Check if any filter is active.
Get the current filter state.
Set filter state.
Notify grid that filters have changed (triggers re-filtering).
Refresh Methods
Refresh specific cells.
Completely redraw rows (removes and recreates DOM).
Export Methods
Export grid data as CSV.
Export grid data as Excel (Enterprise only).
Editing Methods
Start editing a specific cell.
Stop editing.
Common Patterns
Save and Restore Grid State
Export Filtered Data
Bulk Row Selection
Auto-refresh Data
TypeScript Support
The API is fully typed. Use generics for type safety:Best Practices
- Store the API reference - Keep a reference to use throughout your application
- Check isDestroyed() - Before calling API methods on long-lived references
- Use updateGridOptions() - Instead of multiple
setGridOption()calls - Batch operations - Use transactions instead of multiple individual updates
- Leverage events - React to grid events instead of polling the API
- Type your data - Use TypeScript generics for better IDE support
Related
- GridOptions - Configure grid behavior
- Column Definitions - Column API methods
- Row Data - Row manipulation methods