Skip to content

Cell notes ​

You can put a short note on a cell, such as "needs checking". A cell with a note shows a small triangle in its top-right corner, and hovering it shows the text in a tooltip. Notes are not part of your row data. The grid holds them separately, so you can save and restore them without touching rows.

Add and remove notes in the gallery example Cell context menu.

Add a note ​

Users have three ways to add one.

  • Right-click a cell and choose Add note (or Edit note if it already has one).
  • Select a cell and press Shift+F2. The editor opens at once without the menu.
  • Your code calls setCellNote.

The editor is a small text box beside the cell, with a key hint under it.

KeyAction
EnterSaves and closes. Enter during Korean composition does not save
Shift+EnterInserts a line break
EscCloses without saving
Click outsideSaves and closes

Saving an empty note removes it, and leading and trailing spaces are trimmed. Turning the menu off with cellMenu: false also turns off Shift+F2, but setting notes in code keeps working.

Start with notes ​

Give cellNotes a list of { rowKey, columnId, text }. Empty texts and duplicate cells are dropped.

ts
createGrid(el, {
  columns,
  rows,
  rowKey: 'id',
  cellNotes: [
    { rowKey: 2, columnId: 'qty', text: 'Group order, prepare early' },
    { rowKey: 5, columnId: 'price', text: 'Recheck unit price' },
  ],
});

Read and change in code ​

ts
api.setCellNote(2, 'qty', 'Check the quantity'); // add or change
api.setCellNote(2, 'qty', null); // remove. An empty string works too

api.getCellNote(2, 'qty'); // 'Check the quantity', or undefined
api.getCellNotes(); // [{ rowKey, columnId, text }, ...] for saving

setCellNote with a row key that does not exist throws an invalid-option error. Calling it again with the same text does nothing and fires no event.

The list from getCellNotes() can go straight back into cellNotes later. Use it to save notes on a server and restore them when the page opens again.

React to changes ​

cellNoteChanged fires when a note is added, changed or removed. text is null when it was removed.

ts
api.on('cellNoteChanged', ({ rowKey, columnId, text }) => {
  if (text === null) removeNoteOnServer(rowKey, columnId);
  else saveNoteOnServer(rowKey, columnId, text);
});

Tune the note tooltip separately ​

cellNoteOptions (1.5.0) changes only the tooltip of cell notes. Omitted values follow tooltipDelay and tooltipOptions, and column tooltips are not affected.

cellNoteOptionsDefaultMeaning
triggertooltipOptions.trigger'hover' is the mouse (touch presses), 'focus' keyboard focus, 'both' both
showDelaytooltipDelayMilliseconds from hover, focus or touch to showing (0 to 2000), for every trigger
hideDelaytooltipOptions.hideDelayMilliseconds from leaving to hiding (0 to 2000)
  • Unknown keys, wrong types and out-of-range values raise invalid-option. setOptions can change them.
  • On a touch screen, one tap on a note cell shows the note after showDelay (or tooltipDelay when omitted). trigger: 'focus' shows only on focus (a tap moves focus there), so it waits for the same delay after the tap. Tapping elsewhere hides it.
  • With trigger: 'focus' or 'both', keyboard focus also waits for showDelay, and the note does not appear if focus leaves in the meantime.
  • cellNotes (the initial list) and a column's notes: false (no notes in that column) are unchanged. This option only changes how notes are shown.

When sorting, rows or columns change ​

  • A note belongs to a row key and a column id. It follows the same cell through sorting, filtering, paging and column moves.
  • When a row goes away, its notes go too. When you replace all data with setRows, notes for keys that are not in the new data are removed.
  • Hiding a column or dropping it from the column list keeps its notes. They come back when the column is visible again.

See also ​