ColDef interface is used to define the configuration for individual columns in AG Grid. It combines display properties, behavior settings, and event handlers.
Overview
Column definitions are provided via thecolumnDefs property in GridOptions:
Core Interface
ColDef Interface
Column Identification
The unique ID to give the column. This is optional. If missing, the ID will default to the field. If both field and colId are missing, a unique ID will be generated. This ID is used to identify the column in the API for sorting, filtering etc.
The field of the row object to get the cell’s data from. Deep references into a row object is supported via dot notation, i.e
'address.firstLine'.Column Types
A comma separated string or array of strings containing
ColumnType keys which can be used as a template for a column.columnTypes:
Value Handling
Value Getters and Formatters
Value Getters and Formatters
Function or expression. Gets the value from your data for display.Parameters:
params.data: The row dataparams.node: The row nodeparams.getValue(field): Utility to get other column values
A function or expression to format a value, should return a string.
Function or expression. Sets the value into your data for saving. Return
true if the data changed.Function or expression. Parses the value for saving.
Cell Rendering
Provide your own cell Renderer component for this column’s cells. See Cell Renderer for framework specific implementation details.
Params to be passed to the
cellRenderer component.Callback to select which cell renderer to be used for a given row within the same column.
Cell Editing
Set to
true if this column is editable, otherwise false. Can also be a function to have different rows editable.Provide your own cell editor component for this column’s cells. See Cell Editor for details.
Params to be passed to the
cellEditor component.Sorting
Set to
false to disable sorting which is enabled by default.Override the default sorting order by providing a custom sort comparator.Parameters:
valueA,valueB: The values to comparenodeA,nodeB: The corresponding RowNodesisDescending:trueif sort direction isdesc
0: valueA is the same as valueB> 0: Sort valueA after valueB< 0: Sort valueA before valueB
Filtering
Filter to use for this column.
- Set to
trueto use the default filter. - Set to the name of a provided filter:
'agNumberColumnFilter','agTextColumnFilter','agDateColumnFilter','agSetColumnFilter'. - Set to a custom filter component.
Params to be passed to the filter component specified in
filter.Whether to display a floating filter for this column.
Styling
Class to use for the cell. Can be string, array of strings, or function that returns a string or array of strings.Module:
CellStyleModuleAn object of CSS values / or function returning an object of CSS values for a particular cell.Module:
CellStyleModuleRules which can be applied to include certain CSS classes.Module:
CellStyleModuleEvents
Callback for after the value of a cell has changed, either due to editing or the application calling
api.setValue().Callback called when a cell is clicked.
Column Groups
ColGroupDef Interface
A list containing a mix of columns and column groups.
The unique ID to give the column group. This is optional. If missing, a unique ID will be generated.
Set to
true to keep columns in this group beside each other in the grid. Moving the columns outside of the group (and hence breaking the group) is not allowed.Related APIs
Column Properties
Detailed property reference
GridOptions
Grid-level configuration
Cell Renderer
Custom cell rendering