Below are listed all the column API methods.
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).
getColumnFunction | Returns the column with the given colKey, which can either be the colId (a string) or the colDef (an object). | |
getAllColumnsFunction | Returns all the columns, regardless of visible or not. | |
getAllGridColumnsFunction | 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. |
See Column State
getColumnStateFunction | Gets the state of the columns. Typically used when saving column state. | |
applyColumnStateFunction | Applies the state of the columns from a previous state. Returns false if one or more columns could not be found. | |
resetColumnStateFunction | Sets the state back to match the originally provided column definitions. | |
getColumnGroupStateFunction | Gets the state of the column groups. Typically used when saving column group state. | |
setColumnGroupStateFunction | Sets the state of the column group state from a previous state. | |
resetColumnGroupStateFunction | Sets the state back to match the originally provided column definitions. |
See Column Groups
getColumnGroupFunction | Returns the column group with the given name. See Column Groups. | |
setColumnGroupOpenedFunction | Call this if you want to open or close a column group. |
See Column Sizing
setColumnWidthFunction | Sets the column width on a single column. 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. | |
setColumnWidthsFunction | Sets the column widths on multiple columns. This method offers better performance than calling setColumnWidth multiple times. 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. | |
sizeColumnsToFitFunction | 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. | |
autoSizeColumnFunction | Auto-sizes a column based on its contents. | |
autoSizeColumnsFunction | Same as autoSizeColumn, but provide a list of column keys. | |
autoSizeAllColumnsFunction | Calls autoSizeColumns on all displayed columns. |
See Column Moving
moveColumnFunction | 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. | |
moveColumnsFunction | Same as moveColumn but works on list. | |
moveColumnByIndexFunction | Same as moveColumn but works on index locations. |
See Column Pinning
isPinningFunction | Returns true if pinning left or right, otherwise false. | |
isPinningLeftFunction | Returns true if pinning left, otherwise false. | |
isPinningRightFunction | Returns true if pinning right, otherwise false. | |
setColumnPinnedFunction | Sets the column pinned / unpinned. Key can be the column ID, field, ColDef object or Column object. | |
setColumnsPinnedFunction | Same as setColumnPinned, but provide a list of column keys. |
setColumnVisibleFunction | Sets the visibility of a column. Key can be the column ID or Column object. | |
setColumnsVisibleFunction | Same as setColumnVisible, but provide a list of column keys. | |
getDisplayNameForColumnFunction | 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. | |
getDisplayNameForColumnGroupFunction | Returns the display name for a column group (when grouping columns). | |
getDisplayedColAfterFunction | 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. | |
getDisplayedColBeforeFunction | Same as getVisibleColAfter except gives column to the left. | |
getAllDisplayedVirtualColumnsFunction | 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. | |
getDisplayedCenterColumns | 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: Column[] | |
getLeftDisplayedColumnGroups | 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. Returns: ColumnGroupChild[] |
Methods for management of value column aggregates (for aggregating when grouping or pivoting).
getValueColumnsfunction getValueColumns(): Column[];addValueColumnfunction addValueColumn(
colKey: (string | Column)
): void;addValueColumnsaddValueColumn but provide a list.function addValueColumns(
colKeys: (string | Column)[]
): void;removeValueColumnfunction removeValueColumn(
colKey: (string | Column)
): void;removeValueColumnsremoveValueColumns but provide a list.function removeValueColumns(
colKeys: (string | Column)[]
): void;setColumnAggFuncaggFunc can be one of 'min' | 'max' | 'sum'>.function setColumnAggFunc(
key: string | Column,
aggFunc: string
): void;See Row Grouping
getRowGroupColumnsFunction | Get row group columns. | |
setRowGroupColumnsFunction | Set the row group columns. | |
addRowGroupColumnFunction | Add a column to the row groups. | |
addRowGroupColumnsFunction | Same as addRowGroupColumn but provide a list of columns | |
removeRowGroupColumnFunction | Remove a column from the row groups. | |
removeRowGroupColumnsFunction | Same as removeRowGroupColumn but provide a list of columns. | |
moveRowGroupColumnFunction | Move the column to a new position in the row grouping order. |
See Pivoting
isPivotModeFunction | Get the pivot mode. | |
setPivotModeFunction | Set the pivot mode. | |
getPivotColumnsFunction | Get the pivot columns. | |
setPivotColumnsFunction | Set the pivot columns. | |
addPivotColumnFunction | Add a pivot column. | |
addPivotColumnsFunction | Same as addPivotColumn but provide a list of columns. | |
removePivotColumnFunction | Remove a pivot column. | |
removePivotColumnsFunction | Same as removePivotColumn but provide a list of columns. | |
getSecondaryPivotColumnFunction | Returns the pivot column for the given pivotKeys and valueColId. Useful to then call operations on the pivot column. | |
getPrimaryColumnsFunction | Returns the grid's primary columns. See Primary vs Secondary Columns. | |
getSecondaryColumnsFunction | Returns the grid's secondary columns. |