Configuring AG Grid Column Defs at Design Time
Summary
- AdapTable treats each AG Grid ColDef property on a case by case basis
- This page anaylses the different use cases and the general principles involved
AG Grid users define the columns in the Grid using the colDefs property in Grid Options.
This step is mandatory for AdapTable users, also, who will then reference the ColDef Id in their Layouts.
However not all properties in ColDefs are treated equally by AdapTable - some are ignored, some are required and others are used only if the preferred alternative in AdapTable is not provided.
The full details of how AdapTable treats each ColDef property are listed below.
AG Grid and AdapTable each have a mechanism for developers to provide information about Grid Columns:
- AG Grid ColDef Properties - define column behaviour across the Grid
- AdapTable Layouts - define Column behaviour and properties for named sets of Columns
The fundamental difference between the 2 properties is Scope Usage.
Important
- ColDefs set full and exclusive Column behaviour for the lifetime of the Application
- Layouts support multiple, mutually exclusive use cases - Columns can behave differently in different Layouts
Because AdapTable supports multiple Layouts, it cannot simply just read the properties defined in ColDefs.
Note
- This is because 2 different Layouts might want to treat the same Column property differently
- For instance it is very common to set different visibility, column order, or row grouping in different Layouts
As a result, AdapTable needs to decide on initial Layout behaviour on a per-ColDef property basis.
Essentially, AdapTable responds to AG Grid ColDef properties in 3 different ways.
Depending on the use case, it will do one of the following for each property:
- ignore - the property is never invoked or used
- respect - if provided, AdapTable will use it in its own functionality
Caution
- AdapTable generally ignores ColDef props that sets same values as available in Layouts, e.g.
group,pivot,pin - But respects (usually in Layout Editor) ColDef props that set behaviour e.g.
enableGroup,enableValue,resizable
- fall back on - property still works if AdapTable's preferred implementation is not provided
Note
- The majorify of AG Grid's
ColDefproperties do not appear in any of these 3 lists - This is because AdapTable has no direct relationship with them, and they perform their intended AG Grid purpose
Ignored
There are some ColDef properties which AdapTable simply ignores - they are never read nor acted upon.
The intended behaviour needs, instead, to be provided via AdapTable's Layout properties.
Pivoting
| ColDef | AG Grid Purpose | AdapTable Layout Behaviour |
|---|---|---|
pivot | Pivots a Column | Only columns in PivotColumns are pivoted |
initialPivot | Pivots new Column | Only columns in PivotColumns are pivoted |
pivotIndex | Pivot Column index | Columns are pivoted by PivotColumns order |
initialPivotIndex | New Pivot Column index | Columns are pivoted by PivotColumns order |
Row Grouping
| ColDef | AG Grid Purpose | AdapTable Layout Behaviour |
|---|---|---|
rowGroup | Groups a Column | Only columns in RowGroupColumns are grouped |
initialRowGroup | Groups new Column | Only columns in RowGroupColumns are grouped |
rowGroupIndex | Grouped Column index | Columns grouped by RowGroupColumns order |
initialRowGroupIndex | New Grouped Column index | Columns grouped by RowGroupColumns order |
Aggregating
| ColDef | AG Grid Purpose | AdapTable Layout Behaviour |
|---|---|---|
aggFunc | Agg Func | Only Aggregations in TableAggregationColumns are evaluated |
initialAggFunc | New Agg Func | Only Aggregations in TableAggregationColumns are evaluated |
Pinning
| ColDef | AG Grid Purpose | AdapTable Layout Behaviour |
|---|---|---|
pinned | Pins a Column | Only columns in ColumnPinning are pinned |
initialPinned | Pins new Column | Only columns in ColumnPinning are pinned |
lockPinned | Prevents Pinning a Column | Column can still be pinned in Layout and UI |
Sorting
| ColDef | AG Grid Purpose | AdapTable Layout Behaviour |
|---|---|---|
sort | Sorts a Column | Only columns in ColumnSorts are sorted |
initialSort | Sorts new Column | Only columns in ColumnSorts are sorted |
sortIndex | Sorted Column index | Columns sorted by the order in ColumnSorts |
initialSortIndex | New Sorted Column index | Columns sorted by the order in ColumnSorts |
sortingOrder | Order of Sort Directions | Sort Directions provided in ColumnSorts |
Visibility
| ColDef | AG Grid Purpose | AdapTable Layout Behaviour |
|---|---|---|
hide | Hides a Column | Any column in TableColumns is visible (unless overridden in ColumnVisibility) |
initialHide | Hides a new Column | Any column in TableColumns is visible (unless overridden in ColumnVisibility) |
Sizing
| ColDef | AG Grid Purpose | AdapTable Layout Behaviour |
|---|---|---|
initialWidth | Width for new Columns | Only sizing in ColumnSizing is used |
initialFlex | Flex for new Columns | Only sizing in ColumnSizing is used |
Note
- Unlike with most other ColDef properties that have values,
flexandwidthare not ignored by AdapTable - Instead they are used if the Column's property is not explicitly overridden in the Layout's
ColumnSizing
Leveraged
There are many ColDef properties which, if provided, are respected - and used - by AdapTable:
| ColDef | AG Grid Purpose | AdapTable Behaviour |
|---|---|---|
field | Finds item in Grid Data Source | Becomes Adaptable Column field property |
colId | Unique Id for Column | Becomes Adaptable Column columnId property |
type | Used for Column Templating | Used for Column Types Scope |
cellDataType | Column's data type | Used to infer Adaptable Column's Data Type |
enablePivot | Column is Pivotable in UI | Respected by Pivot Layout UI Wizard |
enableRowGroup | Column is Groupable in UI | Respected by Table Layout UI Wizard |
enableValue | Column is Aggregatable in UI | Respected by Pivot Layout UI Wizard |
defaultAggFunc | Default Agg Func | Respected by Table Layout UI Wizard |
allowedAggFuncs | Allowed Agg Funcs | Respected by Table Layout UI Wizard |
sortable | Column is Sortable in UI | Respected by Table Layout UI Wizard |
resizable | Column is Resizable in UI | Respected by Table Layout UI Wizard |
suppressMovable | Column is not Movable in UI | Respected by Table Layout UI Wizard |
Note
The resizable property is only used if it is not explicitly overridden by Resizable in the Layout's ColumnSizing object
AdapTable Preference
There are a few AG Grid ColDef properties for which AdapTable provides an alternative implementation.
These properties will be evaluated, but only if the AdapTable equivalent has not been provided.
Note
- We strongly recommend using the AdapTable equivalent in all these use cases where possible
- Any objects created are saved to AdapTable State and there is tight integration with other AdapTable features
| ColDef | AG Grid Purpose | Preferred AdapTable Equivalent |
|---|---|---|
valueFormatter | Formats a Cell | Display Formats |
comparator | Provides custom sort | Custom Sort |
editable | Sets Column Editability | AdapTable Cell Editability |
In addition, the Layout's ColumnSizing object contains 5 properties which override ColDef props.
However if one of these is not provided, then the ColDef equivalent is used instead:
AdapTable ColumnSizing Property Used if Provided | ColDef Fallback property |
|---|---|
Flex | flex |
Width | width |
MinWidth | minWidth |
MaxWidth | maxWidth |