Configuring Free Text Columns
Summary
- Free Text Columns can be defined at design-time using Free Text Column Initial State
- The Free Text Column API can be used to add values programmatically at run-time
Free Text Columns are defined in initialState.FreeTextColumn.FreeTextColumns — see Free Text Column Initial Adaptable State and FreeTextColumn.
Part of FreeTextColumn | Purpose |
|---|---|
ColumnId | Id used in Layouts, filters, and API |
FriendlyName | Header text in the UI (optional) |
FreeTextColumnSettings | Required DataType; layout flags (Filterable, Sortable, …); optional CellDataType |
DefaultValue | Shown in every cell until the user overrides |
FreeTextStoredValues | Per-row values keyed by PrimaryKey |
Run-time updates use FreeTextColumnApi.setStoredValues (below).
Defining Free Text Columns
Developer Guide
Defining a Free Text Column
There are (up to) 6 properties that you need to provide:
const initialState: InitialState = {
FreeTextColumn: {
FreeTextColumns: [
{
ColumnId: 'comments',
FriendlyName: 'Ops Note',
FreeTextStoredValues: [
{ PrimaryKey: 24195339, FreeText: 'Used by US team' },
{ PrimaryKey: 82095231, FreeText: 'Required by Support' },
],
FreeTextColumnSettings: {
Resizable: true,
DataType: 'text',
},
},
{
ColumnId: 'orderCode',
FriendlyName: 'Order Code',
DefaultValue: 123,
FreeTextColumnSettings: {
DataType: 'number',
Sortable: false,
SuppressMenu: true,
},
},
{
ColumnId: 'isUsed',
FriendlyName: 'Is Used',
DefaultValue: false,
FreeTextColumnSettings: {
DataType: 'boolean',
Filterable: true,
},
},
],
},
};This value is used to refer to the Column in State
This value is used to refer to the Column in AdapTable UI
Whether the Column is Text Number Date or Boolean
Is only mandatory property in FreeTextColumnSettings
AdapTable provides an appropriate Cell Editor based on the DataType provided here
Used in each cell unless explicitly overridden by the User
Initial values to show in the column.
Each is keyed against the Primary Key value for the Row.
Provide additional settings for the Column (e.g. filterable, pivotable, resizable, sortable etc.)
Hint
- To prevent filtering on Free Text Columns, set
enableFilterOnSpecialColumnsto false in Column Filter Options - This will also disallow filtering on all Calculated Columns and Action Columns
Adding Values Programmatically
A commonly used function in Free Text Column API is setStoredValues which allows you to update values stored in Free Text Columns programmatically.
setStoredValues
columnId: string, values: FreeTextStoredValue[], action: 'All' | 'Conflicting' | 'None'void- The demo starts with 3 stored values in the
OpsNoteFree Text column (adaptableOptions.ts) - Each toolbar button applies the same payload : update
Angular(PK24195339), and addReact(PK10270250) - with a differentreplaceAction:- None — only adds the new Stored Value; existing ones are left unchanged
- Conflicting — updates the overlapping Stored Value and adds the new one; other Stored Values remain
- All — replaces every Stored Value with just the payload
- Use Reset to restore the initial 3 Stored Values (
replaceAction: 'All')
Click None, then Reset, and compare with Conflicting and All
AG Grid Column Definitions
Typically Free Text Columns are provided only in Initial Adaptable State and not also defined in Grid Options.
However sometimes it is required to define the Free Text Column in AG Grid - e.g. if you want to show an AG Grid tooltip on the cell value.
This is possible by specifying a Column Type of freeTextColumn in the AG Grid Column Definition.
Hint
Make sure ColId in the Column Definition and ColumnId in the Custom Column definition are the same value
Find Out More
See Adding Special Column Types for more details and an accompanying demo
AG Grid Cell Data Type
AG Grid provides a Cell Data Type (cellDataType) property which can be attached to one, or more, columns.
AdapTable allows users to leverage, and assign, an application-registered AG Grid Cell Data Type when creating a Free Text Column.
Caution
- The
baseDataType(orextendsDataType) must be compatible with the Free Text Column's AdapTableDataType - If this is not provided then AdapTable will use the Free Text Column's
DataTypeproperty
This is done via the optional CellDataType property in FreeTextColumnSettings:
Hint
- The key benefit is the Free Text Column automatically inherits everything the registered Cell Data Type provides
- e.g. its
valueFormatter,valueParserand cell editor
{
ColumnId: 'TargetPrice',
FriendlyName: 'Target Price',
FreeTextColumnSettings: {
DataType: 'number', // AdapTable uses `number` for AQL, filtering and menus...
CellDataType: 'pricing', // ...but AG Grid renders the cell using the registered `pricing` type
},
},- This demo registers 2 custom AG Grid Cell Data Types in
dataTypeDefinitions(in AG Grid GridOptions), each with its ownvalueFormatter:currency- formats a number as a USD currency valuepercentage- formats a number (0-1) as a percentage
- It then defines 2 Free Text Columns which have an AdapTable
DataTypeofnumberbut a differentCellDataType:Target Price- an editable currency value (with 3 initial Stored Values)Completion- an editable percentage value (defaulting to 50%)
- Because the AdapTable
DataTypeis stillnumber, both columns filter, sort and edit as numbers
- Edit a cell in the
Target PriceColumn - you enter a plain number but it displays as currency - Look at
gridOptions.tsto see how thecurrencyandpercentageCell Data Types are registered
AdapTable Resources
- Free Text Columns
- Free Text Column Technical Reference
- Numeric Cell Editor
- Date Picker
- Column Filter Options (
enableFilterOnSpecialColumns) - Adding Special Column Types