# Free Text Columns

Canonical page: https://www.adaptabletools.com/docs/handbook-freetext-column

- Free Text Columns are user-owned columns whose values live in Adaptable State, not the grid Data Source
- Use them for editable per-row fields (ops notes, flags, codes, etc.) that travel with the user layout and state
- Each Free Text Column has a data type of Text, Number, Boolean or Date, plus layout-style settings (filterable, groupable, etc.)
- AdapTable shows an appropriate cell editor when values are added or edited

Free Text Columns are **special columns** where run-time users can enter and save bespoke **column** data.

Values are stored in the user's [Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state/index.md) and are **not** written back to the grid's data source.

Typical uses include an ops-note column, a boolean "in use" flag, or a numeric order code that should persist with AdapTable State rather than the remote dataset.

Free Text Columns — like [Calculated Columns](https://www.adaptabletools.com/docs/handbook-calculated-column/index.md) and [Action Columns](https://www.adaptabletools.com/docs/handbook-action-column/index.md) — are not ordinary data columns; AdapTable creates them dynamically each time the Application runs.

### Free Text Columns vs Calculated, Styled, Notes & Comments

Free Text Columns often sit next to other AdapTable features that also feel like “extra data” on the grid. They overlap in appearance, but each answers a different question.

#### FreeText vs Calculated Columns

Both are **special columns** AdapTable creates at runtime. The difference is the source of truth:

| | FreeText Column | Calculated Column |
| --- | --- | --- |
| Value comes from | User entry (or Initial State / API) | An [AdapTable QL](https://www.adaptabletools.com/docs/adaptable-ql-expression/index.md) expression |
| Editable in the grid? | **Yes** (always) | No — recomputed from other data |
| Persisted | Cell values in [Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state/index.md) | Column definition in State (values are derived) |
| Typical use | Ops note, flag, order code, “in use” | Totals, ratios, derived fields |

Use a Calculated Column when the value should stay in sync with other columns; use FreeText when it is **user-owned** and independent of the Data Source.

#### FreeText vs Styled Columns

Styled Columns do **not** add a column — they change how an existing data column looks:

| | FreeText Column | Styled Column |
| --- | --- | --- |
| What it is | A **new** special column (`ColumnId`, Layout slot, editor) | A **display treatment** on an existing column |
| Underlying value | User-owned FreeText data | The real AG Grid / Data Source value |
| Typical use | Extra editable fields in the Layout | Badges, gradients, sparklines on real data |

You can still apply Format Column or Styled Column rules *to* a FreeText Column after it exists.

#### FreeText vs Notes

Notes annotate a **single cell**; FreeText is **column-shaped**:

| | FreeText Column | Note |
| --- | --- | --- |
| Shape | One value **per row** in that column | Attached to one cell (column + primary key) |
| Audience | Anyone using that Layout / State | Personal to the current user |
| Edited via | Normal cell editing in the column | Note UI / Context Menu |
| Typical use | Dedicated Layout field (filterable, sortable, exportable) | Private reminder on a cell |

#### FreeText vs Comments

Comments are collaborative **cell threads**, not a column of values:

| | FreeText Column | Comment |
| --- | --- | --- |
| Shape | One value **per row** in that column | A Comment Thread on one cell |
| Audience | Anyone using that Layout / State | Shared across team members |
| Persisted | Adaptable State | Remotely (developer-provided persistence) |
| Typical use | Editable per-row field in the grid | Shared discussion on a cell |

Neither Notes nor Comments replace a FreeText Column when you need a dedicated field in the Layout.

- Use a **FreeText Column** when you need an editable, Layout-visible field whose values live in Adaptable State
- Use a **Calculated Column** when the value should be derived from other data via an expression
- Use a **Styled Column** when you only need to render an existing data column differently
- Use a **Note** for a private cell-level reminder; use a **Comment** for shared cell-level discussion

Each Free Text Column can be given a data-type, an optional default value, and pre-populated if required.

Free Text Columns are **not** available if you are using an [auto-generated Primary Key](https://www.adaptabletools.com/docs/getting-started-primary-key/index.md#auto-generated-key)

**Example: Free Text Columns**

Using Free Text Columns in AdapTable

- Three Free Text Columns in Initial State (see `adaptableOptions.ts`):

1. `comments` (**Ops Note**) — **text**, three stored values, _Resizable_
2. `orderCode` (**Order Code**) — **number**, default `123`, menu suppressed
3. `isUsed` (**Is Used**) — **boolean**, default `false`, four stored `true` values, _Filterable_

- Edit cells in the Free Text columns and confirm values persist with Adaptable State (not the Web Frameworks dataset)
- Open **Layout → Free Text Columns** in the Settings Panel to inspect column definitions

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Free Text Column',
  initialState: {
    FreeTextColumn: {
      FreeTextColumns: [
        {
          ColumnId: 'comments',
          FriendlyName: 'Ops Note',
          FreeTextStoredValues: [
            {PrimaryKey: 24195339, FreeText: 'Used by US team'},
            {PrimaryKey: 224663696, FreeText: 'My favourite'},
            {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,
          FreeTextStoredValues: [
            {PrimaryKey: 10270250, FreeText: true},
            {PrimaryKey: 24195339, FreeText: true},
            {PrimaryKey: 224663696, FreeText: true},
            {PrimaryKey: 82095231, FreeText: true},
          ],
          FreeTextColumnSettings: {
            DataType: 'boolean',
            Filterable: true,
            Groupable: true,
          },
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'comments',
            'license',
            'orderCode',
            'language',
            'isUsed',
            'github_watchers',
            'week_issue_change',
            'github_stars',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'open_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

### How Free Text Columns Work in AdapTable

Each time the application starts up AdapTable retrieves any Free Text Column definitions from AdapTable State.

For each Free Text Column definition, AdapTable will then:

1. Create an Adaptable Column
2. Create an equivalent AG Grid column

It is possible to define the Free Text Column in AG Grid Column Definitions and then to bind that AG Grid Column to the Free Text Column definition by using a [Column Type](https://www.adaptabletools.com/docs/dev-guide-columns-column-types/index.md) of `freeTextColumn`

## Column DataType

All Free Text Columns have a **data type** which defines what type of data the column can store.

- The `DataType` property in [`FreeTextColumn`](https://www.adaptabletools.com/docs/reference/freetextcolumn.md) can be set at run-time in the UI using the Free Text Column Wizard
- Or it can be provided at design time - it is the only mandatory property in `FreeTextColumnSettings` object

There are 4 possible values for the Data Type:

AdapTable displays an appropriate cell editor based on the Column's DataType

| DataType | Cell Editor |
| --- | --- |
| **text** (default) | Standard text editor |
| **number** | AdapTable [Numeric Cell Editor](https://www.adaptabletools.com/docs/handbook-cell-editors-numeric/index.md) |
| **boolean** | Checkbox |
| **date** | AdapTable [Date Picker](https://www.adaptabletools.com/docs/handbook-cell-editors-date-picker/index.md) |

If no value is set then the default value of text is used

## Default Value

Free Text Columns can be given a **default value**.

This value is used automatically for every cell in the Column unless specifically overridden by the user.

- The default value is NOT stored in the `FreeTextStoredValues` property, along with hand-edited values
- However it is rendered in the cell each time it is displayed in the UI

This option is available both when defining the column in [Free Text Column Initial Adaptable State](https://www.adaptabletools.com/docs/technical-reference-freetext-column/index.md) at design-time, and when creating it in the UI at run-time.

Make sure to provide a default value which is consistent with the [DataType](#free-text-column-datatype) of the Column

## Default and Pre-Stored Values

When defining Free Text Columns at design-time in [Initial Adaptable State](https://www.adaptabletools.com/docs/technical-reference-freetext-column/index.md), it is possible to provide some initial cell values, using the `FreeTextStoredValues` property.

These values will then display the first-time the Free Text Column is shown (and on all subsequent occasions unless they are overridden).

- You cannot supply Free Text Stored Values when creating the Free Text Column in the UI
- But you can, of course, provide them subsequently simply by editing the cells

## Formatted Free Text Columns

Free Text Columns, once created, are like any other Column and can be treated as such.

This means that they can be used with [Column Formatting](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md) or as a [Styled Column](https://www.adaptabletools.com/docs/handbook-styled-column-overview/index.md).

**Example: Free Text Columns Formatting**

Formatting Free Text Columns in AdapTable

- This example provides 2 Free Text Columns which have been given additional formatting:

1. `Last Spoken` - a **date** column with 1 Stored Value (Date Picker when editing) — we applied a [Display Format](https://www.adaptabletools.com/docs/handbook-column-formatting-display-format/index.md)
2. `Status` - a **text** column with 5 Stored Values: we applied a [Badge Style](https://www.adaptabletools.com/docs/handbook-styled-column-badge/index.md) and also limited the values that can be provided by using an [Select Cell Editor](https://www.adaptabletools.com/docs/handbook-cell-editors-select/index.md)

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Free Text Column Formatted',
  editOptions: {
    showSelectCellEditor: context => {
      return context.column.columnId === 'status';
    },
    customEditColumnValues: context => {
      if (context.column.columnId === 'status') {
        return [
          {label: 'Preferred', value: 'Preferred'},
          {label: 'Allowed', value: 'Allowed'},
          {label: 'On-boarding', value: 'On-boarding'},
          {label: 'Not Allowed', value: 'Not Allowed'},
        ];
      }
      return context.defaultValues;
    },
  },
  initialState: {
    FreeTextColumn: {
      FreeTextColumns: [
        {
          ColumnId: 'lastSpoken',
          FriendlyName: 'Last Spoken',
          FreeTextStoredValues: [
            {PrimaryKey: 24195339, FreeText: new Date(2021, 5, 7)},
          ],
          FreeTextColumnSettings: {
            DataType: 'date',
          },
        },

        {
          ColumnId: 'status',
          FriendlyName: 'Status',
          FreeTextColumnSettings: {
            DataType: 'text',
          },
          FreeTextStoredValues: [
            {PrimaryKey: 10270250, FreeText: 'Preferred'},
            {PrimaryKey: 24195339, FreeText: 'Preferred'},
            {PrimaryKey: 74293321, FreeText: 'Allowed'},
            {PrimaryKey: 224663696, FreeText: 'On-boarding'},
            {PrimaryKey: 76694515, FreeText: 'Not Allowed'},
          ],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'license',
            'lastSpoken',
            'language',
            'status',
            'github_watchers',
            'github_stars',
            'week_issue_change',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'open_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-lastSpoken',
          Scope: {ColumnIds: ['lastSpoken']},
          DisplayFormat: {
            Formatter: 'DateFormatter',
            Options: {
              Pattern: 'yyyy/MM/dd',
            },
          },
        },
      ],
    },
    StyledColumn: {
      StyledColumns: [
        {
          Name: 'status Badge',
          ColumnId: 'status',
          BadgeStyle: {
            Badges: [
              {
                Rule: '[status] = "Preferred"',
                PillStyle: {
                  BackColor: 'var(--ab-color-palette-19)',
                  ForeColor: 'var(--ab-color-palette-14)',
                },
              },
              {
                Rule: '[status] IN ("Allowed", "On-boarding")',
                PillStyle: {
                  BackColor: 'var(--ab-color-palette-32)',
                  ForeColor: 'var(--ab-color-palette-14)',
                },
              },
              {
                Rule: '[status] = "Not Allowed"',
                PillStyle: {
                  BackColor: 'var(--ab-color-palette-30)',
                  ForeColor: 'var(--ab-color-palette-14)',
                },
              },
            ],
          },
        },
      ],
    },
  },
};
```

## Using Free Text Columns

Run-time access to Free Text Columns is available in the Free Text Column section of the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md) (under **Layout**, alongside Calculated Columns).

There is no Free Text Column Toolbar or Tool Panel

This displays a list of existing Free Text Columns with buttons to edit, share or delete each item.

- Free Text Columns **cannot** be suspended
- AdapTable will try to prevent you from deleting a Free Text Column which is referenced elsewhere

There is also an Add button to create new Free Text Columns using the Free Text Column Wizard.

- Newly created Free Text Columns are automatically added to the end of the Current [Layout](https://www.adaptabletools.com/docs/handbook-layouts/index.md)
- Existing Free Text Columns include an `Edit Free Text Column` Menu Item in the [Column Menu](https://www.adaptabletools.com/docs/ui-column-menu/index.md)

### Using the Free Text Column Wizard

There are 6 steps required when creating a Free Text Column:

Provide an Id for the Free Text Column.

This is the value used when referring to the Column in State or in other objects (e.g. Layouts).

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

This defaults to the `ColumnId` value, so only provide the property if you need it to be different

Choose what DataType you require for the Column. Options are:

- Text (the default)
- Number
- Date
- Boolean

AdapTable provides an appropriate Cell Editor based on the Free Text Column's DataType.

If the DataType is `Text`, then you can also choose which `TextEditor` to use; options are:

- `Inline` - the default
- `Large` - useful if providing large quantities of text

- You can also optionally choose a custom [AG Grid Cell Data Type](https://www.adaptabletools.com/docs/dev-guide-aggrid-cell-data-types/index.md) to use for formatting and export
- This dropdown only appears if your application has registered custom AG Grid Cell Data Types (in the `dataTypeDefinitions` property of AG Grid GridOptions) that are compatible with the chosen `DataType`
- See [AG Grid Cell Data Type](https://www.adaptabletools.com/docs/handbook-freetext-column-configuring/index.md#ag-grid-cell-data-type) for more details

Set a Default Value to be displayed in each cell unless explicitly overridden by the User.

Choose which properties the Free Text Column should have (those set to true by default are marked with an asterisk):

- Filterable \*
- Resizable \*
- Groupable
- Sortable \*
- Pivotable
- Aggregatable
- Suppress Menu
- Suppress Movable
- Editable \* (cannot be unchecked)

The new Free Text Column is created and added to the end of the Current [Layout](https://www.adaptabletools.com/docs/handbook-layouts/index.md).

It will be given, where applicable, any properties defined in AG Grid DefaultColDef.

## UI Entitlements

The [UI Entitlements](https://www.adaptabletools.com/docs/handbook-permissioning/index.md) behaviour for Free Text Columns is as expected for `Full` and `Hidden` Access Levels.

The `ReadOnly` Entitlement behaviour is that the Column remains visible and its cells stay editable, but Users cannot edit or delete the column definition.

If you are using an [auto-generated Primary Key](https://www.adaptabletools.com/docs/getting-started-primary-key/index.md#auto-generated-key) then Free Text Columns will **never** be available

### FAQ

**Where is the data stored for Free Text Columns?**
With the User's [Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state/index.md) wherever that is stored, i.e. locally or remotely.
Free Text Column data is **not** stored with the dataset of the underlying grid.

**Why can't I see my Free Text Columns or the Free Text Column Settings Panel?**
Check if you are using an [auto-generated Primary Key](https://www.adaptabletools.com/docs/getting-started-primary-key/index.md#auto-generated-key); if so then Free Text Columns are unavailable as they require a Primary Key that is guaranteed to be consistent between sessions

**Can we refer to the Free Text Column in our AG Grid Column Definitions (e.g. to put it in a Column Group)?**
Yes, you can do that.
You must ensure the `colId` matches the Free Text Column `ColumnId` and add a [Column Type](https://www.adaptabletools.com/docs/dev-guide-columns-column-types/index.md) of _freeTextColumn_

**If I provide a Shortcut for numeric data entry, is this available in Free Text Columns?**
Yes, [Shortcuts](https://www.adaptabletools.com/docs/handbook-editing-shortcut/index.md) will work anywhere where the numeric editor is used, including in numeric Free Text Columns (which have the correct scope)

**Where is my newly created Free Text Column?**
Free Text Columns added through the Free Text Column Wizard get added to the end of the Current Layout.
If provided through Initial Adaptable State, they will need to be explicitly added to the relevant Layout.
