Grid API


sizeColumnsToFit()Gets columns to adjust in size to fit the grid horizontally.
setColumnDefs(colDefs)Call to set new column definitions. The grid will redraw all the column headers, and then redraw all of the rows.


setRowData(rows)Set rows.
updateRowData(transaction)Update row data. Pass a transaction object with lists for add, remove and update.
setDatasource(datasource)Set new datasource. The grid will reset all paging and load the first page. If you want to reset the paging but keep the datasource, call this method with the same datasource.
Methods for getting and setting the data and getting the Row Nodes of the pinned rows.
getModel()Returns the row model inside the table. From here you can see the original rows, rows after filter has been applied, rows after aggregation has been applied, and the final set of 'to be displayed' rows.
refreshClientSideRowModel(params)Gets the Client-side Row Model to refresh, executing the grouping, filtering and sorting again.

Accessing Row Nodes

getRowNode(id)Returns the row node with the given ID. The row node ID is the one you provide with the callback getRowNodeId(data), otherwise the ID is a number auto generated by the grid when the row data is set.
forEachNode(callback(node, index))Iterates through each node (row) in the grid and calls the callback for each node. This works similar to the forEach method on a Javascript array. This is called for every node, ignoring any filtering or sorting applied within the grid. If using infinite row model, then gets called for each page loaded in the page cache.
forEachNodeAfterFilter(callback(node, index))Similar to forEachNode, except skips any filtered out data.
forEachNodeAfterFilterAndSort(callback(node, index))Similar to forEachNode, except skips any filtered out data and the callbacks are called in the order the rows are displayed in the grid.
forEachLeafNode(callback(node, index))Similar to forEachNode, except lists all the leaf nodes. This effectively goes through all the data that you provided to the grid before the grid performed any grouping. If using tree data, goes through all the nodes for the data you provided, including nodes that have children, but excluding groups the grid created where gaps were missing in the hierarchy.
getDisplayedRowAtIndex(index)Returns the displayed rowNode at the given index.
getDisplayedRowCount()Returns the total number of displayed rows.
getFirstDisplayedRow()Get the index of the first displayed row due to scrolling (includes invisible rendered rows in the buffer).
getLastDisplayedRow()Get the index of the last displayed row due to scrolling (includes invisible rendered rows in the buffer).

Master Detail

getDetailGridInfo(detailGridId)Returns the DetailGridInfo corresponding to the supplied detailGridId. See Master Detail.
forEachDetailGridInfo(callback)Iterates through each DetailGridInfo in the grid and calls the supplied callback on each. See Master Detail.


selectAll()Select all rows (even rows that are not visible due to grouping being enabled and their groups not expanded).
deselectAll()Clear all row selections.
selectAllFiltered()Select all filtered rows.
deselectAllFiltered()Clear all filtered selections.
getSelectedNodes()Returns a list of selected nodes. Getting the underlying node (rather than the data) is useful when working with tree / aggregated data, as the node can be traversed.
getSelectedRows()Returns a list of selected rows (i.e. row data that you provided).
getBestCostNodeSelection()Returns a list of all selected nodes at 'best cost', a feature to be used with groups / trees. If a group has all its children selected, then the group appears in the result, but not the children. Designed for use with 'children' as the group selection type, where groups don't actually appear in the selection normally.
getCellRanges()Returns the list of selected cell ranges.
addCellRange(params)Adds to the selected range.
clearRangeSelection()Clears the selected range.


refreshCells(params)Performs change detection on all cells, refreshing cells where required.
redrawRows(params)Remove a row from the DOM and recreate it again from scratch.
refreshHeader()Redraws the header. Useful if a column name changes, or something else that changes how the column header is displayed.
flashCells(params)Flash rows, columns or individual cells. See Flashing Cells.

Sort and Filter

setQuickFilter(quickFilter)Pass a quick filter text into ag-Grid for filtering. If using Angular, the grid watches the quickFilterText attribute of the gridOptions. If you won't want to use quickFilterText (i.e. if not using AngularJS) then you can call this method instead to apply a quick filter.
isQuickFilterPresent()Returns true if the quick filter is set, otherwise false.
isColumnFilterPresent()Returns true if any column filter is set, otherwise false.
isAnyFilterPresent()Returns true if any filter is set. This includes quick filter, advanced filter or external filter.
getFilterInstance(col, callback)Returns the filter component instance for a column. col can be a string field name or a ColDef object (matches on object reference, useful if field names are not unique). For filters that are created asynchronously including React 16+ components, calling this method will return null if the filter has not already been created. If your app uses asynchronous components, use the optional callback function which will be invoked with the filter instance when it is available.
getFilterModel()Gets the current state of all the advanced filters. Used for saving filter state.
setFilterModel(model)Sets the state of all the advanced filters. Provide it with what you get from getFilterModel() to restore filter state.
onFilterChanged()Informs the grid that a filter has changed. This is typically called after a filter change through one of the filter APIs.
destroyFilter()Destroys a filter. Useful to force a particular filter to be created from scratch again.
onSortChanged()Gets the grid to act as if the sort was changed. Useful if you update some values and want to get the grid to reorder them according to the new values.
setSortModel(model)Sets the sort state.
getSortModel()Returns the sort state.
getFocusedCell()Returns the focused cell (or the last focused cell if the grid lost focus) as an object containing the rowIndex, column and floating (which can be 'top', 'bottom' or null).
setFocusedCell(rowIndex, colKey, floating)Sets the focus to the specified cell. Set floating to null, 'top', or 'bottom'.
clearFocusedCell()Clears the focused cell.
tabToNextCell()Navigates the grid focus to the next cell, as if tabbing.
tabToPreviousCell()Navigates the grid focus to the previous cell, as if shift-tabbing.


stopEditing(cancel?)If a cell is editing, it stops the editing. Pass true if you want to cancel the editing (i.e. don't accept changes). See Editing API.
startEditingCell(params)Start editing a particular cell. See Editing API.
getEditingCells()If the grid is editing, returns back details of the editing cell(s). See Editing API.


See Export for more information.

exportDataAsCsv(params)Downloads a CSV export of the grid's data.
getDataAsCsv(params)Similar to exportDataAsCsv, except returns the result as a string rather than download it.
exportDataAsExcel(params)Downloads an Excel export of the grid's data.
getDataAsExcel(params)Similar to exportDataAsExcel, except returns the result as a string rather than download it. This forces exportMode to 'xml'.


addEventListener(eventType, listener)Add an event listener for the specified eventType. Works similar to addEventListener for a browser DOM element.
addGlobalListener(listener)Add an event listener for all event types coming from the grid.
removeEventListener(eventType, listener)Remove an event listener.
removeGlobalListener(listener)Remove a global event listener.
dispatchEvent(event)Dispatch an event through the grid. Useful if you are using a custom cellRenderer and want to fire events such as cellValueChanged.

Row Groups

expandAll()Expand all groups.
collapseAll()Collapse all groups.
setRowNodeExpanded(rowNode, expanded)Expand or collapse a specific row node.
onGroupExpandedOrCollapsed()If after getting the model, you expand or collapse a group, call this method to inform the grid. It will work out the final set of 'to be displayed' rows again (i.e. expand or collapse the group visually).


getRenderedNodes()Retrieve rendered nodes. Due to virtualisation this will contain only the current visible rows and those in the buffer.
getCellRendererInstances(params)Returns the list of active Cell Renderer Instances.
getCellEditorInstances(params)Returns the list of active Cell Editor Instances.
getSizesForCurrentTheme()Gets the sizes that various UI elements will be rendered at with the current theme. Returns an object containing the keys rowHeight and headerHeight. If you override the row or header height using gridOptions, the override value you provided will be returned.


setAlwaysShowVerticalScroll(show)If true, the vertical scrollbar will always be present even if not required, otherwise it will only be displayed when necessary.
ensureIndexVisible(index, position)Ensures the row index is visible by vertically scrolling the grid. The valid values for positions are 'top' | 'middle' | 'bottom' | undefined | null. If 'top', 'middle' or 'bottom', the grid will scroll the row to place the row at the top, middle or bottom respectively. If undefined or null the grid will do the minimum scrolling to show the row, i.e. if the grid needs to scroll up then it will scroll so that the row is at the top, if the grid needs to scroll down then it will scroll so that the row is at the bottom, if the row is already in view then the grid will do nothing.
ensureNodeVisible(comparator, position)Ensures a node is visible, scrolling the table if needed. Provide one of a) the node b) the data object c) a comparator function (that takes the node as a parameter, and returns true for match or false for no match). The valid values for positions are same as for api.ensureIndexVisible().
ensureColumnVisible(colId)Ensures the column is visible, scrolling the table if needed.
getHorizontalPixelRange()Returns a JSON object with two properties:
  • left: The left pixel position of the current scroll in the grid
  • right: The right pixel position of the current scroll in the grid
getVerticalPixelRange()Returns a JSON object with two properties:
  • top: The top pixel position of the current scroll in the grid
  • bottom: The bottom pixel position of the current scroll in the grid

Infinite Scrolling

refreshInfiniteCache()Marks all the currently loaded blocks in the cache for reload. If you have 10 blocks in the cache, all 10 will be marked for reload. The old data will continue to be displayed until the new data is loaded.
purgeInfiniteCache()Purges the cache. The grid is then told to refresh. Only the blocks required to display the current data on screen are fetched (typically no more than 2). The grid will display nothing while the new blocks are loaded. Use this to immediately remove the old data from the user.
getInfiniteRowCount()The row count defines how many rows the grid allows scrolling to.
isMaxRowFound()The property maxRowFound is a boolean, true or false. When false, the grid will allow scrolling beyond the rowCount looking for more rows. When the last row is found, maxRowFound becomes true, and the grid will only scroll to the last available row as it has finished looking for more data.
setInfiniteRowCount(rowCount, maxRowFound)Sets the rowCount and maxRowFound properties. The second parameter, maxRowFound, is optional and if left out, only rowCount is set. Set rowCount to adjust the height of the vertical scroll. Set maxRowFound to enable / disable searching for more rows. Use this method if you add or remove rows into the dataset and need to reset the number of rows or put the data back into 'look for data' mode.
getCacheBlockState()Returns an object representing the state of the cache. This is useful for debugging and understanding how the cache is working.


showLoadingOverlay()Show the 'loading' overlay.
showNoRowsOverlay()Show the 'no rows' overlay.
hideOverlay()Hides the overlay if showing.


copySelectedRangeToClipboard(includeHeaders)Copies the selected ranges to the clipboard.
copySelectedRangeDown()Copies the selected range down, similar to Ctrl + D in Excel.


paginationIsLastPageFound()Returns true when the last page is known; this will always be the case if you are using the Client-side Row Model for pagination. Returns false when the last page is not known; this only happens when using Infinite Scrolling Row Model.

paginationGetPageSize()Returns how many rows are being shown per page.
paginationSetPageSize(newPageSize)Sets the paginationPageSize to newPageSize, then re-paginates the grid so the changes are applied immediately.
paginationGetCurrentPage()Returns the 0-based index of the page which is showing.
paginationGetTotalPages()Returns the total number of pages. Returns null if paginationIsLastPageFound() == false.
paginationGetRowCount()The total number of rows. Returns null if paginationIsLastPageFound() == false.
paginationGoToPage(pageNumber)Goes to the specified page. If the page requested doesn't exist, it will go to the last page.
Shorthands for goToPage(relevantPageNumber).


setHeaderHeight(heightInPx)Sets the height in pixels for the row containing the column label header.
setGroupHeaderHeight(heightInPx)Sets the height in pixels for the rows containing header column groups.
setFloatingFiltersHeight(heightInPx)Sets the height in pixels for the row containing the floating filters.
setPivotHeaderHeight(heightInPx)Sets the height in pixels for the row containing the columns when in pivot mode.
setPivotGroupHeaderHeight(heightInPx)Sets the height in pixels for the row containing header column groups when in pivot mode.

Status Bar

getStatusBarComponent(key)Returns the status bar component instance for the key provided.


getChartModels()Returns a list of models with information about the charts that are currently rendered from the grid.
createRangeChart(params)Used to programmatically create charts from a range. See Range Chart API.
createPivotChart(params)Used to programmatically create pivot charts from a grid. See Pivot Chart API.


setPopupParent(element)DOM element to use as the popup parent for grid popups (context menu, column menu etc).
addRenderedRowListener(event, rowIndex, callback)Registers a callback to a virtual row. A virtual row is a row that is visually rendered on the screen (rows that are not visible because of the scroll position are not rendered). Unlike normal events, you do not need to unregister rendered row listeners. When the rendered row is removed from the grid, all associated rendered row listeners will also be removed. Currently supports only one event, virtualRowRemoved; listen for this event if your cellRenderer needs to do cleanup when the row no longer exists.
showToolPanel(show)Shows (or hides) the tool panel.
isToolPanelShowing()Returns true if the tool panel is showing, otherwise false.
getToolPanelInstance(id)Gets the tool panel instance corresponding to the supplied id. See Expand / Collapse Column Groups.
doLayout()Force the grid to perform a layout of its components. The grid, by default, resizes to fit the div the grid lives in. This is done a) on initialisation b) window resize and c) periodically as defined by layoutInterval (default 500ms). You should call this if something happens in your application where the grid size has changed and you want to lay the grid out without waiting for the next periodic refresh.
getValue(colKey, node)Gets the value for a column for a particular rowNode (row). This is useful if you want the raw value of a cell e.g. if implementing your own CSV export.
destroy()Will destroy the grid and release resources. If you are using Angular (version 1 or 2) you do not need to call this, as the grid links in with the AngularJS 1.x lifecycle. However if you are using Web Components or native Javascript, you do need to call this, to avoid a memory leak in your application.
showColumnMenuAfterButtonClick(colKey, buttonElement), showColumnMenuAfterMouseClick(colKey, mouseEvent)Shows the column menu after and positions it relative to the provided element (button click) or mouse event. Use in conjunction with your own header template.
checkGridSize()Tells the grid to check its size again. This is useful if you do not have the grid in the DOM when you create it, to call this method after the grid is in the DOM to get it to check its width and height again (which decides which columns and rows to render).
resetRowHeights()Tells the grid to recalculate the row heights.
onRowHeightChanged()Tells the grid a row height has changed. To be used after calling rowNode.setRowHeight(newHeight).
copySelectedRowsToClipboard(includeHeaders, columnKeys)Copies the selected rows to the clipboard. Set includeHeaders = true to include the headers (default is false). Set columnKeys to the list of columns if you want just specific columns.
addAggFunc(key, aggFunc), addAggFuncs(aggFuncs), clearAggFuncs()Adding and clearing of aggregation functions.
hidePopupMenu()Hides any showing context menu or column menu.
setSuppressRowDrag(value)Sets the suppressRowDrag property.
setEnableCellTextSelection()Sets the enableCellTextSelection property.
setGridAutoHeight(value)Sets the gridAutoHeight property.
isAnimationFrameQueueEmpty()Returns true when there are no more animation frames left to process.
purgeServerSideCache(route)Purges the server-side cache. If you pass no parameters, then the top level cache is purged. To purge a child cache, pass in the string of keys to get to the child cache. See Purging Groups.