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

Defining Free Text Columns

Free Text Columns can be defined in Free Text Column Initial Adaptable State.

Each FreeTextColumn object contains 2 useful properties that can be provided if required:

  • FreeTextStoredValues - allows the Free Text Column to be 'pre-populated' with relevant data
  • DefaultValue - enables each cell to display a default value unless explicitly overridden by the User
Developer Guide

Defining a Free Text Column

There are (up to) 6 properties that you need to provide:

// Provide 3 Free Text Columns
// 1. OpsNote - string column with 3 initial values
// 2. OrderCode - numeric column with default of 123
// 3. LastSpoken - a date Column
const initialState: InitialState = {
  FreeTextColumn: {
    FreeTextColumns: [
      {
        ColumnId: 'OpsNote',
        FriendlyName: 'Ops Note',
        FreeTextStoredValues: [
          { PrimaryKey: 12, FreeText: 'Dispatch asap' },
          { PrimaryKey: 15, FreeText: 'Angry client' },
          { PrimaryKey: 21, FreeText: 'Big order' },
        ], 
        FreeTextColumnSettings: {
          DataType: 'text',
          Aggregatable: false,
        },
      },
      {
        ColumnId: 'OrderCode',
        FriendlyName: 'Order Code',
        DefaultValue: 123, 
        FreeTextColumnSettings: {
          DataType: 'number',
          Sortable: false,
          SuppressMenu: true,
        },
      },
      {
        ColumnId: 'LastSpoken',
        FriendlyName: 'Last Spoken',
        FreeTextColumnSettings: {
          DataType: 'date',
          Filterable: true,
        },
      },
    ],
  },
}

1
Id for the Free Text Column

This value is used to refer to the Column in State

2
Column Name (if the Id property is not suitable)

This value is used to refer to the Column in AdapTable UI

3
DataType for the Column

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

4
Default Value (Optional)

Used in each cell unless explicitly overridden by the User

5
Initial Stored Values (Optional)

Initial values to show in the column.

Each is keyed against the Primary Key value for the Row.

6
Other Column Settings (Optional

Provide additional settings for the Column (e.g. filterable, pivotable, resizable, sortable etc.)

Hint

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
Adds Stored Values to a FreeText Column
Adding FreeText Values via API
Fork
  • The demo starts with 3 Stored Values in the Ops Note FreeText Column
  • Each toolbar button applies the same payload : update Angular (PK 24195339), and add React (PK 10270250) - with a different replaceAction:
    • 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')
Try It Out

Click None, then Reset, and compare with Conflicting and All

Loading demo…

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