Notes let users attach comments to individual cells without storing note text in row data. Cells with notes are marked in the grid, note actions are available from the context menu, hovering a noted cell opens the built-in resizable note editor, and Shift + F2 opens or creates a note for the focused cell when notes are allowed.
Enabling Notes Copy Link
Notes are enabled by providing a notesDataSource to the grid. The datasource has two required methods getNote() and setNote() and is responsible for managing the state of the notes for the grid. To ensure stable row ids getRowId() is required.
To add a new note either right-click a cell to open the context menu or press Shift + F2. Hovering a cell with a note will display the note popup. Use noteShowDelay and noteHideDelay to control how quickly note popups appear and disappear on hover.
import {
ClientSideRowModelModule,
ColDef,
GetRowIdParams,
GridOptions,
ModuleRegistry,
Note,
NotesDataSource,
NotesDataSourceGetNoteParams,
NotesDataSourceSetNoteParams,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
import { OlympicWinner } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
]);
type OlympicWinner = {
id: string;
athlete: string;
age: number;
country: string;
year: number;
sport: string;
};
const getNoteKey = (rowId: string, colId: string) => `${rowId}::${colId}`;
const noteStore = new Map<string, Note>([
[
getNoteKey("1", "athlete"),
{
text: "Confirm the athlete biography before the next review.",
},
],
[
getNoteKey("3", "country"),
{
text: "Check the latest federation naming guidance for this country.",
},
],
]);
const notesDataSource: NotesDataSource = {
getNote: (params: NotesDataSourceGetNoteParams) =>
noteStore.get(getNoteKey(params.rowNode.id!, params.column.getColId())),
setNote: (params: NotesDataSourceSetNoteParams) => {
const key = getNoteKey(params.rowNode.id!, params.column.getColId());
if (params.note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, params.note);
}
},
};
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete" },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110 },
{ field: "sport" },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
getRowId: ({ data }: GetRowIdParams<OlympicWinner>) => data.id,
defaultColDef: {
flex: 1,
minWidth: 120,
},
notesDataSource,
};
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
createGrid(gridDiv, gridOptions);
.example-wrapper {
display: flex;
flex-direction: column;
gap: 8px;
height: 100%;
}
.example-header {
color: var(--ag-secondary-foreground-color);
}
#myGrid {
flex: 1 1 0;
}
<div class="example-wrapper">
<div id="myGrid"></div>
</div>
Provide a data source to control where notes are stored and retrieved.
Can be updated to enable, disable, or replace Notes at runtime. |
const gridOptions = {
getRowId: (params) => String(params.data.id),
notesDataSource: {
getNote: ({ rowNode, column }) => notesStore[rowNode.id]?.[column.getColId()],
setNote: ({ rowNode, column, note }) => {
const row = (notesStore[rowNode.id] ??= {});
if (note === undefined) {
delete row[column.getColId()];
} else {
row[column.getColId()] = note;
}
},
},
// other grid options ...
} Notes Trigger Copy Link
Use noteTrigger to control whether existing notes open on hover or on left-click. hover is the default. When using click, noteShowDelay no longer applies, but noteHideDelay still controls how long the note stays open after the pointer leaves the cell or popup.
Click mode follows the same passive note rules as hover mode: notes still do not open for the cell currently being edited.
const gridOptions = {
noteTrigger: 'click',
// other grid options ...
}import {
ClientSideRowModelModule,
ColDef,
GetRowIdParams,
GridOptions,
ModuleRegistry,
Note,
NotesDataSource,
NotesDataSourceGetNoteParams,
NotesDataSourceSetNoteParams,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
import { OlympicWinner } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
]);
type OlympicWinner = {
id: string;
athlete: string;
age: number;
country: string;
year: number;
sport: string;
};
const getNoteKey = (rowId: string, colId: string) => `${rowId}::${colId}`;
const noteStore = new Map<string, Note>([
[
getNoteKey("1", "athlete"),
{
text: "Click a noted cell to open this note instead of hovering it.",
},
],
[
getNoteKey("3", "country"),
{
text: "Click trigger still uses the same note datasource and built-in popup.",
},
],
]);
const notesDataSource: NotesDataSource = {
getNote: (params: NotesDataSourceGetNoteParams) =>
noteStore.get(getNoteKey(params.rowNode.id!, params.column.getColId())),
setNote: (params: NotesDataSourceSetNoteParams) => {
const key = getNoteKey(params.rowNode.id!, params.column.getColId());
if (params.note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, params.note);
}
},
};
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete" },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110 },
{ field: "sport" },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
getRowId: ({ data }: GetRowIdParams<OlympicWinner>) => data.id,
defaultColDef: {
flex: 1,
minWidth: 120,
},
noteTrigger: "click",
notesDataSource,
};
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
createGrid(gridDiv, gridOptions);
.example-wrapper {
display: flex;
flex-direction: column;
gap: 8px;
height: 100%;
}
.example-header {
color: var(--ag-secondary-foreground-color);
}
#myGrid {
flex: 1 1 0;
}
<div class="example-wrapper">
<div id="myGrid"></div>
</div>
Changes how existing notes are opened. 'hover' - Existing notes open when hovering a noted cell or full width row. 'click' - Existing notes open when clicking a noted cell or full width row. |
The delay in milliseconds before a note is shown when hovering a noted cell.
Only applies when noteTrigger = 'hover'. |
The delay in milliseconds before a note is hidden after the pointer leaves a noted cell or note popup. |
Metadata Copy Link
Built-in note metadata, including author, createdAt, and updatedAt, is rendered exactly as provided by your datasource.
The built-in note editor only updates the note text. If notes created from the built-in UI should also include metadata, stamp it inside notesDataSource.setNote(). The example below includes an Authenticated User input to simulate the current user being stamped into saved notes.
import {
ClientSideRowModelModule,
ColDef,
GetRowIdParams,
GridOptions,
ModuleRegistry,
Note,
NotesDataSource,
NotesDataSourceGetNoteParams,
NotesDataSourceSetNoteParams,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
import { OlympicWinner } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
]);
type OlympicWinner = {
id: string;
athlete: string;
age: number;
country: string;
year: number;
sport: string;
};
const getNoteKey = (rowId: string, colId: string) => `${rowId}::${colId}`;
const getDisplayTimestamp = () =>
new Intl.DateTimeFormat("en-GB", {
dateStyle: "medium",
timeStyle: "short",
}).format(new Date());
const getCurrentUser = () => {
const user = (
document.getElementById("current-user") as HTMLInputElement | null
)?.value.trim();
return user || undefined;
};
const noteStore = new Map<string, Note>([
[
getNoteKey("1", "athlete"),
{
text: "Confirm the athlete biography before the next review.",
author: "AG Grid",
createdAt: "26 Mar 2026, 10:30",
updatedAt: "29 Mar 2026, 09:15",
},
],
[
getNoteKey("3", "country"),
{
text: "Check the latest federation naming guidance for this country.",
author: "Chris",
createdAt: "24 Mar 2026, 16:10",
updatedAt: "27 Mar 2026, 14:30",
},
],
]);
const notesDataSource: NotesDataSource = {
getNote: (params: NotesDataSourceGetNoteParams) =>
noteStore.get(getNoteKey(params.rowNode.id!, params.column.getColId())),
setNote: (params: NotesDataSourceSetNoteParams) => {
const key = getNoteKey(params.rowNode.id!, params.column.getColId());
const existingNote = noteStore.get(key);
if (params.note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, {
...existingNote,
...params.note,
author: getCurrentUser(),
createdAt: existingNote?.createdAt ?? getDisplayTimestamp(),
updatedAt: getDisplayTimestamp(),
});
}
},
};
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete" },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110 },
{ field: "sport" },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
getRowId: ({ data }: GetRowIdParams<OlympicWinner>) => data.id,
defaultColDef: {
flex: 1,
minWidth: 120,
},
notesDataSource,
};
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
createGrid(gridDiv, gridOptions);
.example-wrapper {
display: flex;
flex-direction: column;
gap: 8px;
height: 100%;
}
.example-toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
.example-field {
display: inline-flex;
align-items: center;
gap: 6px;
}
.example-field input {
padding: 0 0.25rem;
width: 140px;
}
.example-header {
flex: 1 1 320px;
color: var(--ag-secondary-foreground-color);
}
#myGrid {
flex: 1 1 0;
}
<div class="example-wrapper">
<div class="example-toolbar">
<label class="example-field">
<span>Authenticated User</span>
<input id="current-user" type="text" value="AG Grid" />
</label>
</div>
<div id="myGrid"></div>
</div>
const getCurrentUser = () => document.getElementById('current-user').value;
const getDisplayTimestamp = () => new Date().toLocaleString('en-GB');
const gridOptions = {
notesDataSource: {
setNote: ({ rowNode, column, note }) => {
const row = (noteStore[rowNode.id] ??= {});
const colId = column.getColId();
const existingNote = row[colId];
if (note === undefined) {
delete row[colId];
} else {
row[colId] = {
...existingNote,
...note,
author: getCurrentUser(),
createdAt: existingNote?.createdAt ?? getDisplayTimestamp(),
updatedAt: getDisplayTimestamp(),
};
}
},
},
// other grid options ...
} Custom Data Copy Link
Use note.metadata to store any application-defined data alongside the built-in note fields. The Grid preserves this data when the built-in editor updates an existing note, but the built-in note popup does not render it.
The example below stores metadata.type and metadata.priority on notes, then uses application-level cell classes and CSS variables to style note indicators differently. This keeps custom Note data in your datasource while letting your app decide how that data should affect presentation.
import {
CellClassParams,
CellStyleModule,
ClientSideRowModelModule,
ColDef,
GetRowIdParams,
GridOptions,
ModuleRegistry,
Note,
NotesDataSource,
NotesDataSourceGetNoteParams,
NotesDataSourceSetNoteParams,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
CellStyleModule,
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
]);
interface OlympicWinner {
id: string;
athlete: string;
age: number;
country: string;
year: number;
sport: string;
}
interface NoteMetadata {
type: "team" | "review" | "personal";
priority: "high" | "medium" | "low";
}
const getNoteKey = (rowId: string, colId: string) => `${rowId}::${colId}`;
const defaultMetadataByColumn: Record<string, NoteMetadata> = {
athlete: { type: "team", priority: "high" },
country: { type: "review", priority: "medium" },
sport: { type: "personal", priority: "low" },
};
const noteStore = new Map<string, Note<NoteMetadata>>([
[
getNoteKey("1", "athlete"),
{
text: "This team note needs a response before the next content review.",
author: "AG Grid",
updatedAt: "29 Mar 2026, 09:15",
metadata: { type: "team", priority: "high" },
},
],
[
getNoteKey("3", "country"),
{
text: "This review note tracks external naming guidance for this country.",
author: "Chris",
updatedAt: "27 Mar 2026, 14:30",
metadata: { type: "review", priority: "medium" },
},
],
[
getNoteKey("5", "sport"),
{
text: "This personal note is a lightweight reminder for later follow-up.",
author: "Martha",
updatedAt: "28 Mar 2026, 11:45",
metadata: { type: "personal", priority: "low" },
},
],
]);
const getCellNoteMetadata = (
rowId: string,
colId: string,
): NoteMetadata | undefined =>
noteStore.get(getNoteKey(rowId, colId))?.metadata;
const getNoteClasses = (
metadata: NoteMetadata | undefined,
): string[] | undefined =>
metadata
? [`note-type-${metadata.type}`, `note-priority-${metadata.priority}`]
: undefined;
const notesDataSource: NotesDataSource<NoteMetadata> = {
getNote: (params: NotesDataSourceGetNoteParams) =>
noteStore.get(getNoteKey(params.rowNode.id!, params.column.getColId())),
setNote: (params: NotesDataSourceSetNoteParams<NoteMetadata>) => {
const key = getNoteKey(params.rowNode.id!, params.column.getColId());
const existingNote = noteStore.get(key);
if (params.note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, {
...existingNote,
...params.note,
metadata:
existingNote?.metadata ??
defaultMetadataByColumn[params.column.getColId()],
});
}
},
};
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete" },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110 },
{ field: "sport" },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
getRowId: ({ data }: GetRowIdParams<OlympicWinner>) => data.id,
defaultColDef: {
flex: 1,
minWidth: 120,
cellClass: (params: CellClassParams<OlympicWinner>) =>
getNoteClasses(
getCellNoteMetadata(params.node.id!, params.column.getColId()),
),
},
notesDataSource,
};
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
createGrid(gridDiv, gridOptions);
.example-wrapper {
display: flex;
flex-direction: column;
gap: 8px;
height: 100%;
}
.example-toolbar {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.legend-chip {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border: 1px solid var(--ag-border-color);
border-radius: 999px;
background: var(--ag-background-color);
color: var(--ag-foreground-color);
font-size: 12px;
}
.legend-chip::before {
content: '';
width: var(--ag-note-indicator-size, 10px);
height: var(--ag-note-indicator-size, 10px);
border-radius: 999px;
background: var(--ag-note-indicator-color, var(--ag-accent-color));
}
.ag-cell.note-type-team,
.legend-chip.note-type-team {
--ag-note-indicator-color: #2563eb;
}
.ag-cell.note-type-review,
.legend-chip.note-type-review {
--ag-note-indicator-color: #14b8a6;
}
.ag-cell.note-type-personal,
.legend-chip.note-type-personal {
--ag-note-indicator-color: #f59e0b;
}
.ag-cell.note-priority-high,
.legend-chip.note-priority-high {
--ag-note-indicator-size: 12px;
}
.ag-cell.note-priority-medium,
.legend-chip.note-priority-medium {
--ag-note-indicator-size: 10px;
}
.ag-cell.note-priority-low,
.legend-chip.note-priority-low {
--ag-note-indicator-size: 8px;
}
#myGrid {
flex: 1 1 0;
}
<div class="example-wrapper">
<div class="example-toolbar">
<div class="legend-chip note-type-team note-priority-high">Team · High</div>
<div class="legend-chip note-type-review note-priority-medium">Review · Medium</div>
<div class="legend-chip note-type-personal note-priority-low">Personal · Low</div>
</div>
<div id="myGrid"></div>
</div>
const gridOptions = {
defaultColDef: {
cellClass: ({ node, column }) => {
const colId = column.getColId();
const metadata = getCellNoteMetadata(node.id, colId);
if (metadata) {
const { type, priority } = metadata;
return [`note-type-${type}`, `note-priority-${priority}`]
}
},
},
notesDataSource: {
setNote: ({ rowNode, column, note }) => {
const key = `${rowNode.id}::${column.getColId()}`;
const existingNote = noteStore.get(key);
if (note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, {
...existingNote,
...note,
metadata: existingNote?.metadata ?? { type: 'team', priority: 'medium' },
});
}
},
},
// other grid options ...
} Read-Only Notes Copy Link
Set Note.readOnly = true to make a note view-only. Read-only notes can still be opened from hover or click based on noteTrigger, the context menu, or Shift + F2, but they cannot be edited or removed through the built-in UI. The grid API can still update or remove read-only notes programmatically.
Athlete has an editable note. Country and Sport have read-only notes, so they can be viewed but not edited or removed through the built-in UI.
import {
ClientSideRowModelModule,
ColDef,
GetRowIdParams,
GridOptions,
ModuleRegistry,
Note,
NotesDataSource,
NotesDataSourceGetNoteParams,
NotesDataSourceSetNoteParams,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
import { OlympicWinner } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
]);
type OlympicWinner = {
id: string;
athlete: string;
age: number;
country: string;
year: number;
sport: string;
};
const getNoteKey = (rowId: string, colId: string) => `${rowId}::${colId}`;
const noteStore = new Map<string, Note>([
[
getNoteKey("1", "athlete"),
{
text: "This note can still be edited from hover, the context menu, or Shift + F2.",
author: "AG Grid",
updatedAt: "29 Mar 2026, 09:15",
},
],
[
getNoteKey("3", "country"),
{
text: "This note is read-only, so the built-in UI opens it in view-only mode.",
author: "AG Grid",
updatedAt: "27 Mar 2026, 14:30",
readOnly: true,
},
],
[
getNoteKey("5", "sport"),
{
text: "Read-only notes can still show metadata and can still be opened with Shift + F2.",
updatedAt: "28 Mar 2026, 11:45",
readOnly: true,
},
],
]);
const notesDataSource: NotesDataSource = {
getNote: (params: NotesDataSourceGetNoteParams) =>
noteStore.get(getNoteKey(params.rowNode.id!, params.column.getColId())),
setNote: (params: NotesDataSourceSetNoteParams) => {
const key = getNoteKey(params.rowNode.id!, params.column.getColId());
if (params.note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, params.note);
}
},
};
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete" },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110 },
{ field: "sport" },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
getRowId: ({ data }: GetRowIdParams<OlympicWinner>) => data.id,
defaultColDef: {
flex: 1,
minWidth: 120,
},
notesDataSource,
};
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
createGrid(gridDiv, gridOptions);
#myGrid {
height: 100%;
}
<div id="myGrid"></div>
noteStore.set(noteKey('3', 'country'), {
text: 'Check the latest federation naming guidance for this country.',
author: 'AG Grid',
updatedAt: '27 Mar 2026, 14:30',
readOnly: true,
}); Suppressing Note Actions Copy Link
Use colDef.suppressNoteActions to suppress built-in note actions for a column or specific row. Suppressed cells still allow existing notes to be viewed through the configured note trigger and through getNote(), but add/edit/remove actions and note creation shortcuts are blocked.
Year and Sport suppress built-in note actions. Existing notes on those cells can still be viewed normally, while other columns keep the standard add, edit, and remove behaviour.
import {
ClientSideRowModelModule,
ColDef,
GetRowIdParams,
GridOptions,
ModuleRegistry,
Note,
NotesDataSource,
NotesDataSourceGetNoteParams,
NotesDataSourceSetNoteParams,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
import { OlympicWinner } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
]);
type OlympicWinner = {
id: string;
athlete: string;
age: number;
country: string;
year: number;
sport: string;
};
const getNoteKey = (rowId: string, colId: string) => `${rowId}::${colId}`;
const noteStore = new Map<string, Note>([
[
getNoteKey("1", "athlete"),
{
text: "This cell still allows the full built-in note workflow.",
updatedAt: "29 Mar 2026, 09:15",
},
],
[
getNoteKey("2", "year"),
{
text: "Year suppresses note actions, but existing notes still open on hover.",
updatedAt: "28 Mar 2026, 11:45",
},
],
[
getNoteKey("5", "sport"),
{
text: "Sport also suppresses note actions for the entire column.",
updatedAt: "27 Mar 2026, 14:30",
},
],
]);
const notesDataSource: NotesDataSource = {
getNote: (params: NotesDataSourceGetNoteParams) =>
noteStore.get(getNoteKey(params.rowNode.id!, params.column.getColId())),
setNote: (params: NotesDataSourceSetNoteParams) => {
const key = getNoteKey(params.rowNode.id!, params.column.getColId());
if (params.note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, params.note);
}
},
};
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete" },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110, suppressNoteActions: true },
{ field: "sport", suppressNoteActions: true },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
getRowId: ({ data }: GetRowIdParams<OlympicWinner>) => data.id,
defaultColDef: {
flex: 1,
minWidth: 120,
},
notesDataSource,
};
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
createGrid(gridDiv, gridOptions);
#myGrid {
height: 100%;
}
<div id="myGrid"></div>
const gridOptions = {
columnDefs: [
{ field: 'athlete' },
{ field: 'year', suppressNoteActions: true },
{ field: 'sport', suppressNoteActions: params => params.data?.sport === 'Swimming' },
],
// other grid options ...
} Full Width Rows Copy Link
To support adding notes to full width rows ensure the notesDataSource implements the FullWidthNotesDataSource interface. The interface requires supportsFullWidthRows:true to be set on the notesDataSource.
The example below includes both regular notes on cells and notes on full width rows in the same datasource. Full width rows use a separate note identity. Instead of receiving a column, the datasource receives location: 'fullWidthRow' and an optional pinned value when in embedFullWidthRows mode.
import {
ClientSideRowModelModule,
ColDef,
FullWidthNotesDataSource,
FullWidthNotesDataSourceGetNoteParams,
FullWidthNotesDataSourceSetNoteParams,
GetRowIdParams,
GridOptions,
ICellRendererComp,
ICellRendererParams,
IsFullWidthRowParams,
ModuleRegistry,
Note,
RowHeightParams,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
]);
interface OlympicWinner extends Partial<IOlympicData> {
id: string;
featured?: boolean;
}
const noteStore = new Map<string, Note>([
[
"cell::1::athlete",
{
text: "This note belongs to a regular cell.",
},
],
[
"fullWidth::2",
{
text: "This note belongs to a full width row. The datasource receives location: fullWidthRow instead of a column.",
},
],
]);
const getNoteKey = (rowId: string, colId: string) => `cell::${rowId}::${colId}`;
const getFullWidthNoteKey = (rowId: string) => `fullWidth::${rowId}`;
const notesDataSource: FullWidthNotesDataSource = {
supportsFullWidthRows: true,
getNote: (params: FullWidthNotesDataSourceGetNoteParams) =>
params.location === "fullWidthRow"
? noteStore.get(getFullWidthNoteKey(params.rowNode.id!))
: noteStore.get(getNoteKey(params.rowNode.id!, params.column.getColId())),
setNote: (params: FullWidthNotesDataSourceSetNoteParams) => {
const key =
params.location === "fullWidthRow"
? getFullWidthNoteKey(params.rowNode.id!)
: getNoteKey(params.rowNode.id!, params.column.getColId());
if (params.note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, params.note);
}
},
};
class FullWidthCellRenderer implements ICellRendererComp {
private eGui!: HTMLElement;
public init(params: ICellRendererParams<OlympicWinner>): void {
const data = params.data!;
const eGui = document.createElement("div");
eGui.className = "notes-full-width-row";
eGui.innerHTML = `
<div class="notes-full-width-row__title">${data.athlete}</div>
<div class="notes-full-width-row__details">
<span>${data.country}</span>
<span>${data.year}</span>
<span>${data.sport}</span>
</div>
`;
this.eGui = eGui;
}
public getGui(): HTMLElement {
return this.eGui;
}
public refresh(): boolean {
return false;
}
}
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete" },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110 },
{ field: "sport" },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
featured: true,
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
featured: true,
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
getRowId: ({ data }: GetRowIdParams<OlympicWinner>) => data.id,
defaultColDef: {
flex: 1,
minWidth: 120,
},
notesDataSource,
getRowHeight: (params: RowHeightParams<OlympicWinner>) => {
if (params.data?.featured) {
return 96;
}
},
isFullWidthRow: (params: IsFullWidthRowParams<OlympicWinner>) =>
!!params.rowNode.data?.featured,
fullWidthCellRenderer: FullWidthCellRenderer,
};
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
createGrid(gridDiv, gridOptions);
.example-wrapper {
display: flex;
flex-direction: column;
gap: 8px;
height: 100%;
}
.example-header {
color: var(--ag-secondary-foreground-color);
}
#myGrid {
flex: 1 1 0;
}
.notes-full-width-row {
display: flex;
box-sizing: border-box;
flex-direction: column;
gap: 6px;
height: 100%;
justify-content: center;
padding: 0 16px;
border: 1px solid transparent;
background: color-mix(in srgb, var(--ag-accent-color) 10%, var(--ag-background-color));
}
.notes-full-width-row__badge {
font-size: 11px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--ag-secondary-foreground-color);
}
.notes-full-width-row__title {
font-size: calc(var(--ag-font-size) + 2px);
font-weight: 600;
}
.notes-full-width-row__details {
display: flex;
flex-wrap: wrap;
gap: 12px;
color: var(--ag-secondary-foreground-color);
}
.notes-full-width-row__hint {
color: var(--ag-secondary-foreground-color);
font-size: calc(var(--ag-font-size) - 1px);
}
.ag-row:focus .notes-full-width-row {
border-color: var(--ag-range-selection-border-color);
}
<div class="example-wrapper">
<div id="myGrid"></div>
</div>
const notesStore = new Map();
const gridOptions = {
getRowId: (params) => String(params.data.id),
notesDataSource: {
// Enable support for Full Width Rows
supportsFullWidthRows: true,
getNote: (params) =>
params.location === 'fullWidthRow'
? notesStore.get(getFullWidthNoteKey(params.rowNode.id))
: notesStore.get(getNoteKey(params.rowNode.id, params.column.getColId())),
setNote: (params) => {
const key =
params.location === 'fullWidthRow'
? getFullWidthNoteKey(params.rowNode.id)
: getNoteKey(params.rowNode.id, params.column.getColId());
if (params.note === undefined) {
notesStore.delete(key);
} else {
notesStore.set(key, params.note);
}
},
},
// other grid options ...
}notesStore.set('2', {
text: 'This note belongs to a full width row.',
}); Embedded Full Width Rows Copy Link
When embedFullWidthRows=true, the datasource still receives location: 'fullWidthRow', but pinned identifies whether the note belongs to the left, centre, or right rendered section so that the notesDataSource can save the note appropriately.
import {
ClientSideRowModelModule,
ColDef,
FullWidthNotesDataSource,
FullWidthNotesDataSourceGetNoteParams,
FullWidthNotesDataSourceSetNoteParams,
GetRowIdParams,
GridOptions,
ICellRendererComp,
ICellRendererParams,
IsFullWidthRowParams,
ModuleRegistry,
Note,
RowHeightParams,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
]);
interface OlympicWinner extends Partial<IOlympicData> {
id: string;
featured?: boolean;
}
const getSection = (pinned: "left" | "right" | null | undefined) =>
pinned ?? "center";
const getFullWidthNoteKey = (
rowId: string,
pinned: "left" | "right" | null | undefined,
) => `${rowId}::${getSection(pinned)}`;
const noteStore = new Map<string, Note>([
[
getFullWidthNoteKey("2", "left"),
{
text: "This note belongs to the left embedded full width section.",
},
],
[
getFullWidthNoteKey("2", undefined),
{
text: "This note belongs to the centre embedded full width section.",
},
],
[
getFullWidthNoteKey("2", "right"),
{
text: "This note belongs to the right embedded full width section.",
},
],
]);
const notesDataSource: FullWidthNotesDataSource = {
supportsFullWidthRows: true,
getNote: (params: FullWidthNotesDataSourceGetNoteParams) =>
params.location === "fullWidthRow"
? noteStore.get(getFullWidthNoteKey(params.rowNode.id!, params.pinned))
: undefined,
setNote: (params: FullWidthNotesDataSourceSetNoteParams) => {
if (params.location !== "fullWidthRow") {
return;
}
const key = getFullWidthNoteKey(params.rowNode.id!, params.pinned);
if (params.note === undefined) {
noteStore.delete(key);
} else {
noteStore.set(key, params.note);
}
},
};
class FullWidthCellRenderer implements ICellRendererComp {
private eGui!: HTMLElement;
public init(params: ICellRendererParams<OlympicWinner>): void {
const data = params.data!;
const section = getSection(params.pinned);
const eGui = document.createElement("div");
eGui.className = `notes-full-width-row notes-full-width-row--${section}`;
eGui.innerHTML = `
<div class="notes-full-width-row__badge">${section}</div>
<div class="notes-full-width-row__title">${data.athlete}</div>
<div class="notes-full-width-row__details">
<span>${data.country}</span>
<span>${data.year}</span>
<span>${data.sport}</span>
</div>
`;
this.eGui = eGui;
}
public getGui(): HTMLElement {
return this.eGui;
}
public refresh(): boolean {
return false;
}
}
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete", pinned: "left", width: 235 },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110 },
{ field: "sport", pinned: "right", width: 235 },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
featured: true,
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
featured: true,
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
embedFullWidthRows: true,
getRowId: ({ data }: GetRowIdParams<OlympicWinner>) => data.id,
defaultColDef: {
flex: 1,
minWidth: 120,
},
notesDataSource,
getRowHeight: (params: RowHeightParams<OlympicWinner>) => {
if (params.data?.featured) {
return 96;
}
},
isFullWidthRow: (params: IsFullWidthRowParams<OlympicWinner>) =>
!!params.rowNode.data?.featured,
fullWidthCellRenderer: FullWidthCellRenderer,
};
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
createGrid(gridDiv, gridOptions);
.example-wrapper {
display: flex;
flex-direction: column;
gap: 8px;
height: 100%;
}
#myGrid {
flex: 1 1 0;
}
.notes-full-width-row {
display: flex;
box-sizing: border-box;
flex-direction: column;
gap: 6px;
height: 100%;
justify-content: center;
padding: 0 16px;
border: 1px solid transparent;
background: color-mix(in srgb, var(--ag-accent-color) 10%, var(--ag-background-color));
}
.notes-full-width-row__badge {
font-size: 11px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--ag-secondary-foreground-color);
}
.notes-full-width-row__title {
font-size: calc(var(--ag-font-size) + 2px);
font-weight: 600;
}
.notes-full-width-row__details {
display: flex;
flex-wrap: wrap;
gap: 12px;
color: var(--ag-secondary-foreground-color);
}
.ag-row:focus .notes-full-width-row {
border-color: var(--ag-range-selection-border-color);
}
<div class="example-wrapper">
<div id="myGrid"></div>
</div>
Feature Interaction Copy Link
Context Menu Copy Link
When the ContextMenuModule is registered, the note actions are included automatically. If you customise getContextMenuItems(), include the built-in note item to keep the standard note actions:
const gridOptions = {
getContextMenuItems: () => ['note', 'copy', 'export'],
// other grid options ...
}The built-in note item expands based on the current cell state:
Add Notewhen the cell has no note and note creation is allowed.Edit NoteandRemove Notewhen the existing note is editable.View Note, plus a disabledRemove Note, when the existing note is read-only.- Disabled note actions when the cell is suppressed. Existing suppressed notes still show
View Note.
Keyboard Shortcuts Copy Link
Shift + F2 opens an existing note for the focused cell, or creates a new note if the cell allows notes and does not already have one. Plain F2 keeps the normal cell editing behaviour.
Cell Editing Copy Link
Notes are not displayed if the cell is currently being edited. Hovering that cell or pressing Shift + F2 will have no effect until editing is complete.
API Copy Link
Use the grid API to read, write, remove and refresh notes programmatically. This is useful when notes are edited from application UI outside the grid, or when the underlying note store changes directly. The API example also shows how to set readOnly on a note payload.
In the example below:
- clicking a cell selects it and syncs the toolbar controls automatically.
Save via APIupdates the note withsetNote(), including setting or clearingreadOnly.Remove via APIclears the noteMutate Store DirectlyplusRefresh Notesshows how to resync the grid after external store updates.
import {
CellFocusedEvent,
ClientSideRowModelModule,
ColDef,
Column,
GetRowIdParams,
GridApi,
GridOptions,
IRowNode,
ModuleRegistry,
Note,
NotesDataSource,
NotesDataSourceGetNoteParams,
NotesDataSourceSetNoteParams,
RowApiModule,
createGrid,
enableDevValidations,
} from "ag-grid-community";
import { ContextMenuModule, NotesModule } from "ag-grid-enterprise";
import { OlympicWinner } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ContextMenuModule,
NotesModule,
RowApiModule,
]);
type OlympicWinner = {
id: string;
athlete: string;
age: number;
country: string;
year: number;
sport: string;
};
let gridApi: GridApi<OlympicWinner>;
type SelectedCell = {
rowNode: IRowNode<OlympicWinner>;
column: Column;
};
const getDisplayTimestamp = () =>
new Intl.DateTimeFormat("en-GB", {
dateStyle: "medium",
timeStyle: "short",
}).format(new Date());
const noteStore: Record<string, Record<string, Note>> = {
"2": {
athlete: {
text: "Follow up with the regional team before publishing this profile.",
author: "Martha",
readOnly: true,
updatedAt: "29 Mar 2026, 09:15",
},
},
};
const notesDataSource: NotesDataSource = {
getNote: (params: NotesDataSourceGetNoteParams) =>
noteStore[params.rowNode.id!]?.[params.column.getColId()],
setNote: (params: NotesDataSourceSetNoteParams) => {
const rowId = params.rowNode.id!;
const colId = params.column.getColId();
if (params.note === undefined) {
delete noteStore[rowId]?.[colId];
} else {
const row = (noteStore[rowId] ??= {});
row[colId] = params.note;
}
},
};
const columnDefs: ColDef<OlympicWinner>[] = [
{ field: "athlete" },
{ field: "age", maxWidth: 110 },
{ field: "country" },
{ field: "year", maxWidth: 110 },
{ field: "sport" },
];
const rowData: OlympicWinner[] = [
{
id: "1",
athlete: "Michael Phelps",
age: 23,
country: "United States",
year: 2008,
sport: "Swimming",
},
{
id: "2",
athlete: "Usain Bolt",
age: 22,
country: "Jamaica",
year: 2008,
sport: "Athletics",
},
{
id: "3",
athlete: "Simone Biles",
age: 19,
country: "United States",
year: 2016,
sport: "Gymnastics",
},
{
id: "4",
athlete: "Katie Ledecky",
age: 19,
country: "United States",
year: 2016,
sport: "Swimming",
},
{
id: "5",
athlete: "Allyson Felix",
age: 30,
country: "United States",
year: 2016,
sport: "Athletics",
},
{
id: "6",
athlete: "Mo Farah",
age: 33,
country: "Great Britain",
year: 2016,
sport: "Athletics",
},
];
const getRowId = ({ data }: GetRowIdParams<OlympicWinner>) => data.id;
const gridOptions: GridOptions<OlympicWinner> = {
columnDefs,
rowData,
getRowId,
defaultColDef: {
flex: 1,
minWidth: 120,
},
notesDataSource,
onCellFocused: (event: CellFocusedEvent<OlympicWinner>) => {
const win = window as any;
win.selectedCell = {
rowNode: gridApi.getDisplayedRowAtIndex(event.rowIndex!),
column: event.column,
};
syncNote(gridApi);
},
};
const getSelectionStatusElement = () =>
document.getElementById("selection-status") as HTMLElement;
const getAuthorInput = () =>
document.getElementById("note-author") as HTMLInputElement;
const getNoteTextArea = () =>
document.getElementById("note-text") as HTMLTextAreaElement;
const getReadOnlyInput = () =>
document.getElementById("note-readonly") as HTMLInputElement;
const describeCell = (cell: SelectedCell) =>
`${cell.rowNode.data?.athlete ?? cell.rowNode.id} / ${cell.column.getColId()}`;
const setStatus = (message: string) => {
getSelectionStatusElement().textContent = message;
};
const getSelectedCell = (): SelectedCell | undefined => {
const win = window as any;
const selectedCell = win.selectedCell as SelectedCell | undefined;
if (!selectedCell) {
setStatus("No cell selected.");
return undefined;
}
return selectedCell;
};
const syncNote = (gridApi: GridApi<OlympicWinner>) => {
const cell = getSelectedCell();
if (!cell || !gridApi) {
return;
}
const note = gridApi.getNote(cell);
getNoteTextArea().value = note?.text ?? "";
getAuthorInput().value =
(note?.author ?? getAuthorInput().value) || "API Demo";
getReadOnlyInput().checked = !!note?.readOnly;
setStatus(
note
? `Loaded note for ${describeCell(cell)}.`
: `No note stored for ${describeCell(cell)}.`,
);
};
function saveSelectedNote() {
const cell = getSelectedCell();
if (!cell || !gridApi) {
return;
}
const text = getNoteTextArea().value.trim();
const author = getAuthorInput().value.trim();
const readOnly = getReadOnlyInput().checked;
const nextNote = text
? {
text,
author: author || undefined,
readOnly: readOnly || undefined,
updatedAt: getDisplayTimestamp(),
}
: undefined;
gridApi.setNote({
...cell,
note: nextNote,
});
syncNote(gridApi);
setStatus(
text
? `Saved note for ${describeCell(cell)} via gridApi.setNote().`
: `Removed note for ${describeCell(cell)} via gridApi.setNote().`,
);
}
function removeSelectedNote() {
const cell = getSelectedCell();
if (!cell || !gridApi) {
return;
}
gridApi.setNote({
...cell,
note: undefined,
});
syncNote(gridApi);
setStatus(`Removed note for ${describeCell(cell)} via gridApi.setNote().`);
}
function mutateStoreDirectly() {
const cell = getSelectedCell();
if (!cell) {
return;
}
const rowId = cell.rowNode.id!;
const colId = cell.column.getColId();
const currentNote = noteStore[rowId]?.[colId];
const author = getAuthorInput().value.trim() || "External Store";
const text =
getNoteTextArea().value.trim() ||
currentNote?.text ||
"Updated outside the grid";
const readOnly = getReadOnlyInput().checked;
const row = (noteStore[rowId] ??= {});
row[colId] = {
...(currentNote ?? {}),
text: `${text} (external update)`,
author,
readOnly: readOnly || undefined,
updatedAt: getDisplayTimestamp(),
};
setStatus(`Updated the store directly for ${describeCell(cell)}.`);
}
function refreshSelectedNotes() {
const cell = getSelectedCell();
if (!cell || !gridApi) {
return;
}
gridApi.refreshNotes({
rowNodes: [cell.rowNode],
columns: [cell.column],
});
syncNote(gridApi);
setStatus(
`Refreshed notes for ${describeCell(cell)} via gridApi.refreshNotes().`,
);
}
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);
if (typeof window !== "undefined") {
// Attach external event handlers to window so they can be called from index.html
(<any>window).saveSelectedNote = saveSelectedNote;
(<any>window).removeSelectedNote = removeSelectedNote;
(<any>window).mutateStoreDirectly = mutateStoreDirectly;
(<any>window).refreshSelectedNotes = refreshSelectedNotes;
}
.example-wrapper {
display: flex;
flex-direction: column;
gap: 10px;
height: 100%;
}
.toolbar {
display: flex;
flex-direction: column;
gap: 8px;
}
.toolbar-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.toolbar-row button {
margin-bottom: 0 !important;
}
.toolbar-field {
display: inline-flex;
align-items: center;
gap: 6px;
}
.toolbar-field input[type='text'] {
padding: 0 0.25rem;
width: 140px;
}
#selection-status {
color: var(--ag-secondary-foreground-color);
}
#note-text {
min-height: 72px;
resize: vertical;
}
#myGrid {
flex: 1 1 0;
}
<div class="example-wrapper">
<div class="toolbar">
<div class="toolbar-row">
<span id="selection-status">No cell selected.</span>
</div>
<div class="toolbar-row">
<label class="toolbar-field">
<span>Author</span>
<input id="note-author" type="text" value="API Demo" />
</label>
<label class="toolbar-field">
<span>Read-only</span>
<input id="note-readonly" type="checkbox" />
</label>
<button onclick="saveSelectedNote()">Save via API</button>
<button onclick="removeSelectedNote()">Remove via API</button>
<button onclick="mutateStoreDirectly()">Mutate Store Directly</button>
<button onclick="refreshSelectedNotes()">Refresh Notes</button>
</div>
<textarea id="note-text" rows="3" placeholder="Edit note text."></textarea>
</div>
<div id="myGrid"></div>
</div>
Grid Options Copy Link
Changes how existing notes are opened. 'hover' - Existing notes open when hovering a noted cell or full width row. 'click' - Existing notes open when clicking a noted cell or full width row. |
The delay in milliseconds before a note is shown when hovering a noted cell.
Only applies when noteTrigger = 'hover'. |
The delay in milliseconds before a note is hidden after the pointer leaves a noted cell or note popup. |
API Reference Copy Link
Return the current note for a cell. |
Set or remove the note for a cell.
Pass note: undefined to remove the note. |
Refresh note presence for the currently rendered cells. |
NotesDataSource Copy Link
Properties available on the NotesDataSource<TMetadata = any> interface.
Return the note for the given cell. |
Set or clear the note for the given cell. |
Initialise the data source so that the user can take a reference to the gridApi if needed. |
Called by the grid when the data source is being disposed. |
FullWidthNotesDataSource Copy Link
Properties available on the FullWidthNotesDataSource<TMetadata = any> interface.
Enables full width row notes for this datasource. |
Return the note for the given cell or full width row. |
Set or clear the note for the given cell or full width row. |
Initialise the data source so that the user can take a reference to the gridApi if needed. |
Called by the grid when the data source is being disposed. |
Note Copy Link
Text content of the note. |
Set to true to make this note readonly. |
Optional author of the note. |
Optional creation timestamp. |
Optional updated timestamp. |
Optional application metadata to be associated with this note. |
RefreshNotesParams Copy Link
Only refresh the provided rowNodes. If undefined refresh all rows. |
Only refresh the provided columns. If undefined refresh all columns. |