# Configuring Notes

Canonical page: https://www.adaptabletools.com/docs/handbook-notes-configuring

- Developers can configure which Cells in the Grid are able to receive Notes
- Notes can be given a Type that colours the cell indicator
- AG Grid GridOptions control whether Notes open on hover or click

Configure Notes through `noteOptions` in [Adaptable Options](https://www.adaptabletools.com/docs/technical-reference-adaptable-options/index.md) and through AG Grid Note settings on `gridOptions`.

[`NoteOptions`](https://www.adaptabletools.com/docs/reference/noteoptions.md) defines **three** AdapTable properties (all covered below). Hover timing and click vs hover use AG Grid’s `noteTrigger`, `noteShowDelay`, and `noteHideDelay` — see [Opening Notes](https://www.adaptabletools.com/docs/handbook-notes-configuring/index.md#opening-notes).

| Property | Section |
| -------- | ------- |
| `isCellNotable` | Notable Cells |
| `defaultNoteType` | Note Types |
| `dateFormat` | Timestamp Format |

Indicator and popup theming use AdapTable Note Type CSS and the [AG Grid Theme](https://www.adaptabletools.com/docs/handbook-theming-aggrid/index.md) — see Theming Notes.

## Notable Cells

By default all cells in AG Grid - even readonly ones - can receive a Note.

### `isCellNotable`

Function enabling specific Cells to be excluded from Notes

The function receives a [`NotableCellContext`](https://www.adaptabletools.com/docs/reference/notablecellcontext.md) (including the `gridCell`) and returns whether that Cell can show Notes.

```ts {3-12}
noteOptions: {
  isCellNotable: (context: NotableCellContext) => {
    // Don't allow Notes on the language column or rows where license is 'Other'
    if (context.gridCell.column.columnId === 'language') {
      return false;
    }
    if (context.gridCell.rowNode.data['license'] === 'Other') {
      return false;
    }
    return true;
  },
},
```

**Example: Configuring Notable Cells**

Setting which Cells can display Notes

- `isCellNotable` in `adaptableOptions.ts` blocks Notes when:
  - the cell is in the `language` column
  - the row’s `license` value is `Other`

- Right-click a cell in the `name` column — *Add Note* is available
- Right-click a cell in `language`, or any cell in a row whose `license` is `Other` — *Add Note* is not offered

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 {NotableCellContext} from '@adaptabletools/adaptable';
import {AdaptableOptions} from '@adaptabletools/adaptable';

import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Notable Cells',
  userName: 'Demo User',
  noteOptions: {
    isCellNotable: (context: NotableCellContext) => {
      // Dont allow Notes on the Language Column or Rows where License is 'Other'
      if (context.gridCell.column.columnId === 'language') {
        return false;
      }

      if (context.gridCell.rowNode.data['license'] === 'Other') {
        return false;
      }
      return true;
    },
  },

  initialState: {
    Dashboard: {
      ModuleButtons: ['Note'],
    },
    Theme: {CurrentTheme: 'dark'},

    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'github_stars',
            'license',
            'github_watchers',
            'language',
            'open_issues_count',
            'closed_issues_count',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'description',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Note Types

Each Note has a `NoteType` of `Info`, `Warning`, `Error` or `Success`, which colours the triangle in the noted Cell:

| Type    | Default Colour and CSS Variable                                                                                                |
| ------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Info    | <div style={{background: 'var(--ab-color-info)', padding: '0.5rem', borderRadius: 5}}>var(--ab-color-info)</div>               |
| Success | <div style={{background: 'var(--ab-color-success)', padding: '0.5rem', borderRadius: 5}}>var(--ab-color-success)</div>         |
| Warning | <div style={{background: 'var(--ab-color-warn)', padding: '0.5rem', borderRadius: 5}}>var(--ab-color-warn)</div>               |
| Error   | <div style={{background: 'var(--ab-color-destructive)', padding: '0.5rem', borderRadius: 5}}>var(--ab-color-destructive)</div> |

New Notes default to `Info`.

Use `defaultNoteType` in [Note Options](https://www.adaptabletools.com/docs/technical-reference-notes/index.md) to stamp a different Type on creation

### `defaultNoteType`

Type given to a Note on creation

Set this when every new Note should start as, for example, a Warning.

```ts {3}
  noteOptions: {
    defaultNoteType: 'Warning',
  },
```

Run-time users change the Type of an existing Note in two places:

- _Set Note Type_ in the [Context Menu](https://www.adaptabletools.com/docs/ui-context-menu/index.md)
- the Type column in the Notes [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md)

## Theming Notes

Notes have **two** themeable surfaces, and each is styled in a different way:

- **The cell indicator triangle** - drawn by AG Grid, but AdapTable recolours it _per Note Type_ by setting `--ag-note-indicator-color` on noted cell

Override the `ab-NoteType-<Type>` classes to change these colours

- **The in-cell Note popup / editor** - drawn entirely by AG Grid

- Theme this through your [AG Grid Theme](https://www.adaptabletools.com/docs/handbook-theming-aggrid/index.md)
- Do it either via the Theming API `withParams` or the matching `--ag-note-popup-*` CSS variables

### Understanding AG Grid Theming Parameters

The AG Grid parameters (and their equivalent CSS variables) for the Notes popup are:

| Theming API Parameter           | AG Grid CSS Variable                     | Themes                  |
| ------------------------------- | ---------------------------------------- | ----------------------- |
| `notePopupBackgroundColor`      | `--ag-note-popup-background-color`       | Popup background        |
| `notePopupTextColor`            | `--ag-note-popup-text-color`             | Popup (read) text       |
| `notePopupInputBackgroundColor` | `--ag-note-popup-input-background-color` | Editor input background |
| `notePopupInputTextColor`       | `--ag-note-popup-input-text-color`       | Editor input text       |
| `notePopupBorder`               | `--ag-note-popup-border`                 | Popup border            |
| `notePopupPadding`              | `--ag-note-popup-padding`                | Popup padding           |

**Example: Notes CSS**

Theming the Note triangle (AdapTable) and the Note popup (AG Grid)

- **Triangle** — `styles.css` sets `--ag-note-indicator-color` for `ab-NoteType-Info`
- **Popup / editor** — `gridOptions.ts` uses the AG Grid Theming API (`notePopup*` parameters)
- Hover a noted cell in `name` or `license` to see the themed popup

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

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template + shown below]
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,
  CustomContextMenuContext,
} from '@adaptabletools/adaptable';

import {WebFramework} from './rowData';
import {
  AdaptableContextMenuItemName,
  AdaptableSystemContextMenuItem,
} from '@adaptabletools/adaptable';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Notes CSS',
  userName: 'Demo User',
  contextMenuOptions: {
    customContextMenu: (customMenuContext: CustomContextMenuContext) => {
      const agGridNote = customMenuContext.defaultAgGridMenuStructure.find(
        item => 'name' in item && item.name === 'note'
      );
      const adaptableNoteItems =
        customMenuContext.defaultAdaptableMenuStructure.filter(
          (
            item
          ): item is AdaptableSystemContextMenuItem<AdaptableContextMenuItemName> =>
            item !== '-' && item.category === 'Note'
        );
      return [...(agGridNote ? [agGridNote] : []), ...adaptableNoteItems];
    },
  },
  initialState: {
    Dashboard: {
      ModuleButtons: ['Note'],
    },
    Theme: {CurrentTheme: 'dark'},

    Note: {
      Notes: [
        {
          PrimaryKeyValue: 10270250,
          Text: 'We are using this Framework',
          ColumnId: 'name',
          Author: 'Demo User',
          NoteType: 'Info',
          CreatedAt: new Date().setDate(new Date().getDate() - 1),
        },
        {
          PrimaryKeyValue: 11730342,
          Text: 'Popular with the Accounts team',
          ColumnId: 'name',
          Author: 'Demo User',
          NoteType: 'Success',
          CreatedAt: new Date().setDate(new Date().getDate() - 2),
        },
        {
          PrimaryKeyValue: 82095231,
          Text: 'Need to find out Stencil license',
          ColumnId: 'license',
          Author: 'Demo User',
          NoteType: 'Warning',
          CreatedAt: new Date().setDate(new Date().getDate() - 3),
        },
        {
          PrimaryKeyValue: 5532320,
          Text: 'Need to find out Polymer license',
          ColumnId: 'license',
          Author: 'Demo User',
          NoteType: 'Error',
          CreatedAt: new Date().setDate(new Date().getDate() - 4),
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'github_stars',
            'license',
            'github_watchers',
            'language',
            'open_issues_count',
            'closed_issues_count',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'description',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/gridOptions.ts`**

```ts
import {GridOptions, themeQuartz} from 'ag-grid-enterprise';

import {rowData, WebFramework} from './rowData';
import {columnDefs} from './columnDefs';

export const gridOptions: GridOptions<WebFramework> = {
  // The in-cell Note popup / editor is drawn by AG Grid, so it is themed via the
  // AG Grid Theming API - here we recolour the popup and its text input.
  theme: themeQuartz.withParams({
    notePopupBackgroundColor: '#fff9c4',
    notePopupTextColor: '#4a3f00',
    notePopupInputBackgroundColor: '#fffde7',
    notePopupInputTextColor: '#4a3f00',
    notePopupBorder: {color: '#e6c74b', width: 1},
  }),
  defaultColDef: {
    resizable: true,
    sortable: true,
    editable: true,
    filter: true,
    floatingFilter: true,
  },
  columnDefs: columnDefs,
  rowData: rowData,
  sideBar: true,
  suppressMenuHide: true,
  columnMenu: 'new',
  cellSelection: true,
};
```

**`src/styles.css`**

```css
/* Recolour the Info Note triangle (AG Grid draws it via --ag-note-indicator-color) */
:root.ab--theme-dark .ab-NoteType-Info {
  --ag-note-indicator-color: yellow;
}
```

## Timestamp Format

AdapTable formats the `Created` and `Last Updated` timestamps shown in both the AG Grid Note popup and in the Notes Settings Panel.

The property is available in [Note Options](https://www.adaptabletools.com/docs/technical-reference-notes/index.md) and returns a string (optionally via a function if required).

### `dateFormat`

Date Format to use for timestamps in Notes

By default AdapTable will format timestamps using 'dd-MM-yyyy HH:mm:ss'.

Use this property to set an alternative Date Format, including via a function if preferred.

```ts {3}
  noteOptions: {
    // Provide custom Date Format
    dateFormat: 'MMM do yyyy',
  },
```

## Opening Notes

By default run-time users see a Note when the mouse hovers over a cell that contains one.

If hover is not wanted, set AG Grid's `noteTrigger` to `'click'` in `GridOptions` so the Note opens when the cell is clicked instead.

- The [Context Menu](https://www.adaptabletools.com/docs/ui-context-menu/index.md) still offers *View Note* / *Edit Note*
- And `Shift + F2` still opens or creates a Note on the focused cell

**Example: Notes Click Trigger**

Opening Notes on click instead of hover

- `noteTrigger: 'click'` in `gridOptions.ts` — hovering a noted cell does nothing

- Click a noted cell (e.g. Angular in `name`) to open its Note
- Hovering the same cell will not open the Note

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

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts
  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: 'Opening Notes on Click',
  userName: 'Demo User',

  initialState: {
    Dashboard: {
      ModuleButtons: ['Note'],
    },
    Theme: {CurrentTheme: 'dark'},
    Note: {
      Notes: [
        {
          PrimaryKeyValue: 10270250,
          Text: 'We are using this Framework',
          ColumnId: 'name',
          Author: 'Demo User',
          NoteType: 'Info',
          CreatedAt: new Date().setDate(new Date().getDate() - 1),
        },
        {
          PrimaryKeyValue: 11730342,
          Text: 'Popular with the Accounts team',
          ColumnId: 'name',
          Author: 'Demo User',
          NoteType: 'Success',
          CreatedAt: new Date().setDate(new Date().getDate() - 2),
        },
        {
          PrimaryKeyValue: 82095231,
          Text: 'Need to find out Stencil license',
          ColumnId: 'license',
          Author: 'Demo User',
          NoteType: 'Warning',
          CreatedAt: new Date().setDate(new Date().getDate() - 3),
        },
        {
          PrimaryKeyValue: 5532320,
          Text: 'Need to find out Polymer license',
          ColumnId: 'license',
          Author: 'Demo User',
          NoteType: 'Error',
          CreatedAt: new Date().setDate(new Date().getDate() - 4),
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'github_stars',
            'license',
            'github_watchers',
            'language',
            'open_issues_count',
            'closed_issues_count',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'description',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/gridOptions.ts`**

```ts
import {GridOptions, themeBalham} from 'ag-grid-enterprise';

import {rowData, WebFramework} from './rowData';
import {columnDefs} from './columnDefs';

export const gridOptions: GridOptions<WebFramework> = {
  theme: themeBalham,
  noteTrigger: 'click',
  defaultColDef: {
    resizable: true,
    sortable: true,
    editable: true,
    filter: true,
    floatingFilter: true,
  },
  columnDefs: columnDefs,
  rowData: rowData,
  sideBar: true,
  suppressMenuHide: true,
  columnMenu: 'new',
  cellSelection: true,
  statusBar: {
    statusPanels: [
      {statusPanel: 'agTotalRowCountComponent', align: 'left'},
      {statusPanel: 'agFilteredRowCountComponent'},
      {
        key: 'Center Panel',
        statusPanel: 'AdaptableStatusPanel',
        align: 'center',
      },
    ],
  },
  columnTypes: {
    github: {},
    'issue-pr': {},
  },
};
```

[AG Grid](https://www.ag-grid.com/javascript-data-grid/notes/) also provides `noteShowDelay` and `noteHideDelay` (milliseconds) to tune hover timing
