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 an ID).

sizeColumnsToFit(width)Gets the grid to size the columns to the specified width in pixels, e.g. 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 colKey, which 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 e.g. if implementing your own cell navigation.
getDisplayedColBefore(col)Same as getVisibleColAfter except gives column 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.
getPrimaryColumns()Returns the grid's primary columns.
getSecondaryColumns()Returns the grid's secondary columns.
getAllDisplayedVirtualColumns()Same as getAllGridColumns(), except only returns rendered columns, i.e. columns that are not within the viewport and therefore not rendered, due to column virtualisation, are not displayed.
Returns all columns currently displayed (e.g. are visible and if in a group, the group is showing the columns) for the pinned left, centre and pinned right portions of the grid.
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 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. aggFunc can be 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, and defaults to true.
moveRowGroupColumn(fromIndex, toIndex)
Methods for management of column row groups.
Methods for management of column pivots.
Methods to get / set the pivot mode.
getSecondaryPivotColumn(pivotKeys, valueColId)Returns the pivot column for the given pivotKeys and valueColId. Useful to then call operations on the pivot column.
Methods for management of value column aggregates (for aggregating when grouping or pivoting).