# String Display Format

Canonical page: https://www.adaptabletools.com/docs/handbook-column-formatting-display-format-string

- AdapTable provides a number of Display Formats to be used with String Columns

AdapTable ships with a number of System String Display Formats.

These are designed to provide Display Formats for string columns.

They are contained in the [`String Formatter`](https://www.adaptabletools.com/docs/reference/stringformatteroptions.md) object defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [Case](https://www.adaptabletools.com/docs/reference/stringformatteroptions.md#case) | `'Upper' \| 'Lower' \| 'Sentence'` | Sets text to Upper, Lower or Sentence case |
| [Content](https://www.adaptabletools.com/docs/reference/stringformatteroptions.md#content) | `string` | Replaces cell value; useful when using Condition (e.g. replace null with &#39;N/A&#39;) |
| [Empty](https://www.adaptabletools.com/docs/reference/stringformatteroptions.md#empty) | `boolean` | Show nothing in cell (but underlying value remains) |
| [Prefix](https://www.adaptabletools.com/docs/reference/stringformatteroptions.md#prefix) | `string` | Prefix to use before the cell text |
| [Suffix](https://www.adaptabletools.com/docs/reference/stringformatteroptions.md#suffix) | `string` | Suffix to use after the cell text |
| [Trim](https://www.adaptabletools.com/docs/reference/stringformatteroptions.md#trim) | `boolean` | Trims text (both start and end) |

There are no presets available for string columns

**Example: Column Formatting: String Display Formats**

Column Formatting with String Display Formats

- In this example 4 System String Display Formats are provided:
  - `Name` is **uppercase**
  - `Language` is given a **Prefix** of 'Lang-' 
  - `Description` is set to **Content** of "[Too long to show...]" - using Condition (leveraging the `LEN` [AdapTableQL Expression Function](https://www.adaptabletools.com/docs/adaptable-ql-expression-functions/index.md)) that cell value is over 100 characters
  - `License` shows as **Empty** - using Condition where Cell Value was 'Other'

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: 'String Display Formats',
  initialState: {
    Dashboard: {
      ModuleButtons: ['FormatColumn'],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'description',
            'license',
            'created_at',
            'updated_at',
            'week_issue_change',
            'github_stars',
            'closed_pr_count',
          ],
          ColumnSorts: [
            {
              ColumnId: 'week_issue_change',
              SortOrder: 'Asc',
            },
          ],
          AutoSizeColumns: true,
        },
      ],
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-name',
          Scope: {
            ColumnIds: ['name'],
          },
          DisplayFormat: {
            Formatter: 'StringFormatter',
            Options: {
              Case: 'Upper',
              Trim: false,
            },
          },
        },
        {
          Name: 'formatColumn-language',
          Scope: {
            ColumnIds: ['language'],
          },
          DisplayFormat: {
            Formatter: 'StringFormatter',
            Options: {
              Prefix: 'Lang: ',
            },
          },
        },
        {
          Name: 'formatColumn-description',
          Scope: {
            ColumnIds: ['description'],
          },
          DisplayFormat: {
            Formatter: 'StringFormatter',
            Options: {
              Content: '[Too long to show...]',
            },
          },
          Rule: 'LEN([description])  > 75',
        },
        {
          Name: 'formatColumn-license',
          Scope: {
            ColumnIds: ['license'],
          },
          DisplayFormat: {
            Formatter: 'StringFormatter',
            Options: {
              Empty: true,
            },
          },
          Rule: '[license] = "Other"',
        },
      ],
    },
  },
};
```

### FAQ

**Are there string Display Format presets?**
No. String columns use `StringFormatter` options only (`Case`, `Trim`, `Prefix`, `Suffix`, `Content`, `Empty`).

**Can we replace long text with a fixed message?**
Yes. Set `Content` to the replacement text and add a [Condition](https://www.adaptabletools.com/docs/handbook-column-formatting-conditions/index.md) (as in the demo for `Description` / `License`).

**Can we hide the cell text but keep the value?**
Yes. Set `Empty: true` (often with a Condition). The underlying value is unchanged.
