#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.
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.
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:
| Type | Colour |
|---|---|
error | red |
warning | yellow |
success | green |
info | blue |
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_admincan edit anyone's entries, but only whenuserInfo.authis 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:
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
threadsin initial or persisted state are ignored.loadThreadsruns once after hydration and replaces them. threadsis left out of the persisted grid state.- An add, edit, or delete updates the grid immediately, then calls
persistThreads. If the result includesthreads, that map replaces the local one. If it throws, orstatusis'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(...):
<script setup lang="ts">
import { Adaptable, type AdaptableProps } from '@adaptabletools/datagrid-vue';
declare const props: AdaptableProps;
const events: AdaptableProps['events'] = {
onCellNoteChange: ({ action, thread }) => {
console.log(action, thread.columnId, thread.primaryKey);
},
onCellNoteMention: ({ entry, initialLoad }) => {
if (!initialLoad) {
console.log(`${entry.author?.userName} mentioned you`);
}
},
};
</script>
<template>
<Adaptable.Provider v-bind="props" :events="events" />
</template>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 v-bind="props">
<Adaptable.UI />
<Adaptable.UI.CellNotesManager />
</Adaptable.Provider>useCellNotes() returns a ref of the threads, the unread counts, and which
thread the popover has open. Changes go through adaptableApi.cellNoteApi.
import { useCellNotes } from '@adaptabletools/datagrid-vue';
// in the setup of a component rendered inside the provider
const cellNotesRef = useCellNotes();
function onToolbarAction() {
// read `.value` when you need it (the template unwraps the ref)
const {
allThreads,
unreadCount,
unreadMentions,
getThreads, // (filter: 'all' | 'unread' | 'mentioned' | 'participating')
} = cellNotesRef.value;
// mutations: adaptableApi.cellNoteApi.addEntry / openNotes / markAllRead
}#Permissions
| Permission | What it allows |
|---|---|
cellNote_view | See notes, the settings page, and the widget |
cellNote_create | Add a note |
cellNote_edit | Edit an entry you are allowed to change |
cellNote_delete | Delete an entry or a thread |
cellNote_admin | Edit any entry, when userInfo.auth is set |
Roles: cellNoteViewer (cellNote_view) and cellNoteAdmin (all of the
above). See Permissioning.