Expand All

  Getting Started



  Row Models




  Third Party


Github stars make projects look great. Please help, donate a star, it's free.
Read about ag-Grid's Partnership with webpack.
Get informed on releases and other ag-Grid news only - never spam.
Follow on Twitter

Column API

Below are listed all the column API methods.

Column Keys

Some of the API methods take Column Key (named colKey) which has type Column|string. This means you can pass either a Column object (that you receive from calling one of the other methods) or you pass in the Column ID (which is a string). The Column ID is a property of the column definition. If you do not provide the Column ID, the grid will create one for you (first by trying to use the field if it is unique, otherwise it will generate and ID).

Column API
sizeColumnsToFit(width) Gets the grid to size the columns to the specified with, eg sizeColumnsToFix(900). To have the grid fit the columns to the grid's width, use the Grid API gridApi.sizeColumnsToFit() instead.
setColumnGroupOpened(group, newValue) Call this if you want to open or close a column group.
getColumnGroup(name) Returns the column group with the given name.
getDisplayNameForColumn(column) Returns the display name for a column. Useful if you are doing your own header rendering and want the grid to work out if headerValueGetter is used, or if you are doing your own column management GUI, to know what to show as the column name.
getDisplayNameForColumnGroup(columnGroup) Returns the display name for a column group (when grouping columns).
getColumn(colKey) Returns the column with the given 'key'. The key can either be the colId (a string) or the colDef (an object).
getColumnState() Gets the state of the columns. Typically used when saving column state.
setColumnState(columnState) Sets the state of the columns from a previous state. Returns false if one or more columns could not be found.
resetColumnState() Sets the state back to match the originally provided column definitions.
getColumnGroupState() Gets the state of the column groups. Typically used when saving column group state.
setColumnGroupState(columnState) Sets the state of the column group state from a previous state.
resetColumnGroupState() Sets the state back to match the originally provided column definitions.
isPinning() Returns true if pinning left or right, otherwise false.
isPinningLeft() Returns true if pinning left, otherwise false.
isPinningRight() Returns true if pinning right, otherwise false.
getDisplayedColAfter(col) Returns the column to the right of the provided column, taking into consideration open / closed column groups and visible columns. This is useful if you need to know what column is beside yours eg if implementing your own cell navigation.
getDisplayedColBefore(col) Same as getVisibleColAfter except gives col to the left.
setColumnVisible(colKey, visible) Sets the visibility of a column. Key can be the column id or Column object.
setColumnsVisible(colKeys, visible) Same as setColumnVisible, but provide a list of column keys.
setColumnPinned(colKey, pinned) Sets the column pinned / unpinned. Key can be the column id, field, ColDef object or Column object.
setColumnsPinned(colKeys, pinned) Same as setColumnPinned, but provide a list of column keys.
autoSizeColumn(colKey) Auto-sizes a column based on its contents.
autoSizeColumns(colKeys) Same as autoSizeColumn, but provide a list of column keys.
getAllColumns() Returns all the columns, regardless of visible or not.
getAllGridColumns() Returns all the grid columns, same as getAllColumns(), except a) it has the order of the columns that are presented in the grid and b) it's after the 'pivot' step, so if pivoting, has the value columns for the pivot.
getAllDisplayedVirtualColumns() Same as getAllGridColumns(), except only returns rendered columns - ie columns not within the viewport that are not rendered, due to column virtualisation, are not displayed.
getDisplayedCenterColumns(), getDisplayedLeftColumns(), getDisplayedRightColumns(), getAllDisplayedColumns() Returns all columns currently displayed (eg are visible and if in a group, the group is showing the columns) for the pinned left, center and pinned right portions of the grid.
getLeftDisplayedColumnGroups(), getCenterDisplayedColumnGroups(), getRightDisplayedColumnGroups(), getAllDisplayedColumnGroups() Returns all 'root' column headers. If you are not grouping columns, these return the columns. If you are grouping, these return the top level groups - you can navigate down through each one to get the other lower level headers and finally the columns at the bottom.
moveColumn(colKey, toIndex) Moves a column to toIndex. The column is first removed, then added at the 'toIndex' location, thus index locations will change to the right of of the column after the removal
moveColumns(colKeys[], toIndex) Same as moveColumn but works on list.
moveColumnByIndex(fromIndex, toIndex) Same as moveColumn but works on index locations.
setColumnAggFunc(column, aggFunc) Sets the agg function for a column. Set to one of [min,max,sum].
setColumnWidth(column, newWidth, finished=true) Sets the column width. The finished flag gets included in the resulting event and not used internally by the grid. The finished flag is intended for dragging, where a dragging action will produce many 'columnWidth' events, so the consumer of events knows when it receives the last event in a stream. The finished parameter is optional, it defaults to 'true'.
getRowGroupColumns(), addRowGroupColumn(colKey), addRowGroupColumns(colKeys), removeRowGroupColumn(colKey), removeRowGroupColumns(colKeys), setRowGroupColumns(colKeys), moveRowGroupColumn(fromIndex, toIndex) Methods for management of column row groups.
getPivotColumns(), setPivotColumns(colKeys), removePivotColumn(), removePivotColumns(colKeys), addPivotColumn(colKey), addPivotColumns(colKeys) Methods for management of column pivots.
isPivotMode(), setPivotMode(mode) Methods to get / set the pivot mode.
getSecondaryPivotColumn(pivotKeys, valueColId) Returns the pivot column for the given pivotKeys and valueColumn. Useful to then call operations on the pivot column.
getValueColumns(), removeValueColumn(colKey), removeValueColumns(colKeys), addValueColumn(colKey), addValueColumns(colKeys) Methods for management of value column aggregates (for aggregating when grouping or pivoting).