Adaptable

#Cell Notes

A cell note is a thread attached to one cell: each entry has an author, a time, and an optional type and mentions. One entry reads as a note; more entries are a discussion. Notes annotate the row's data. They are not part of a view, so every view shows the same threads.

The thread for a cell is stored under primaryKey|columnId in cellNote. By default that map is saved with the rest of the grid state. Two grids can share it — the demo below is two people looking at the same rows.

#
Two people, one set of notes

The top grid is you, the one below is Ana. Ana has already left a warning on Emma's salary, which is unread for you. Double-click a cell to write a note. Mention the other person with @ — their grid picks the note up, and a mention they have not opened shows on the dashboard badge.

open
loading demo…

The two grids do not share Adaptable state. They share a small in-memory store through loadThreads / persistThreads. When one grid saves, it calls cellNoteApi.setThreads on the other. That push does not persist again, and a new mention of the person watching that grid is reported in the usual way. Read marks stay on the user who made them.

#The marker

A cell with a thread shows a triangle in the top-right corner. The colour is the strongest type in the thread:

TypeColour
errorred
warningyellow
successgreen
infoblue

An entry with no type counts as info. A thread you have not opened, written by someone else, shows a larger triangle. Opening the thread marks it read, and the marker goes back to the small one. Your own entries are never unread.

#Adding and editing

  • Context menu on a cell: Add note, Show notes, or Delete notes.
  • Double-click a cell that already has notes to open the thread. On a non-editable cell with no notes, double-click starts one. An editable cell with no notes still edits the value; use the context menu to add the first note.
  • The popover lists every entry and a composer. You can edit or delete your own entries. cellNote_admin can edit anyone's entries, but only when userInfo.auth is set — without it, that permission is not treated as an override.

The Type menu (info, success, warning, error, or none) only changes the marker. It does not change the cell value.

#Mentions

Type @ in the composer. The suggestions come from resolveMentions on defaultState.cellNote. Without that hook, they are the authors already present in the threads. Mentions are stored on the entry when it is written; editing the text later does not re-parse names that were never picked.

In the demo, resolveMentions returns the two people, so either grid can mention the other before they have written anything.

#Storing notes yourself

Leave the hooks off and threads and readMarks are saved with the grid state. To keep them on your backend, supply both hooks of a pair on defaultState.cellNote:

Threads and read marks on the app backend
const state: AdaptableUserState = {
  cellNote: {
    threads: {},
    readMarks: {},
    loadThreads: async ({ stateKey }) => fetchNotes(stateKey),
    persistThreads: async (threads, _change, { stateKey }) => saveNotes(stateKey, threads),
    loadReadMarks: async ({ stateKey, user }) => fetchReadMarks(stateKey, user.userId),
    persistReadMarks: async (readMarks, _change, { stateKey, user }) =>
      saveReadMarks(stateKey, user.userId, readMarks),
  },
  view: {
    currentViewId: 'default',
    views: [{ id: 'default', label: 'Default' }],
  },
};

When both loadThreads and persistThreads are present:

  • Any threads in initial or persisted state are ignored. loadThreads runs once after hydration and replaces them.
  • threads is left out of the persisted grid state.
  • An add, edit, or delete updates the grid immediately, then calls persistThreads. If the result includes threads, that map replaces the local one. If it throws, or status is 'rejected', the change is rolled back and a notification is shown.
  • A newer save that starts while an older one is still in flight discards the older result.

loadReadMarks / persistReadMarks follow the same contract, on their own. A failed read-mark save is rolled back quietly.

One hook of a pair without the other is a configuration error: Adaptable warns once and keeps that field in local grid state.

Other open grids, or a websocket, should push with cellNoteApi.setThreads(threads). That replaces the slice, does not call persistThreads, and fires mention alerts for entries the current user had not seen. setReadMarks does the same for read marks.

isCellNotable decides which cells can take a note (default: every cell). canEdit decides who can change an entry (default: its author, and entries with no author).

#Events

onCellNoteChange and onCellNoteMention are keys of the events prop, same as onAlertTrigger. They also fire for adaptableApi.eventApi.on(...):

Listening to note events
<Adaptable.Provider
  {...props}
  events={{
    onCellNoteChange: ({ action, thread }) => {
      console.log(action, thread.columnId, thread.primaryKey);
    },
    onCellNoteMention: ({ entry, initialLoad }) => {
      if (!initialLoad) {
        console.log(`${entry.author?.userName} mentioned you`);
      }
    },
  }}
/>;

onCellNoteMention fires even when notifyOnMention is false. That flag only turns off the built-in alert, so you can show your own. initialLoad is true for mentions found while threads are first loaded, and false when someone writes one.

#Managing notes in the UI

The settings panel has a Cell Notes page with All, Unread, Mentions, and My threads, and a second row that narrows those by type. A thread stays listed when any of its notes has the chosen type. Each row can jump to the cell or delete the thread. The cellNote dashboard widget opens that page and shows an unread count and a mention count.

The same page can sit in your own layout:

<Adaptable.Provider {...theProps}>
  <Adaptable.UI />
  <Adaptable.UI.CellNotesManager />
</Adaptable.Provider>

useCellNotes() reads the threads, the unread counts, and which thread the popover has open. Changes go through adaptableApi.cellNoteApi.

import { useCellNotes } from '@adaptabletools/datagrid-react';

function MyNotesToolbar() {
  const {
    allThreads,
    unreadCount,
    unreadMentions,
    getThreads, // (filter: 'all' | 'unread' | 'mentioned' | 'participating')
  } = useCellNotes();

  // mutations: adaptableApi.cellNoteApi.addEntry / openNotes / markAllRead
  void allThreads;
  void unreadCount;
  void unreadMentions;
  void getThreads;
}

#Permissions

PermissionWhat it allows
cellNote_viewSee notes, the settings page, and the widget
cellNote_createAdd a note
cellNote_editEdit an entry you are allowed to change
cellNote_deleteDelete an entry or a thread
cellNote_adminEdit any entry, when userInfo.auth is set

Roles: cellNoteViewer (cellNote_view) and cellNoteAdmin (all of the above). See Permissioning.