Skip to content

Events

The onChange callback fires whenever the user interacts with the spreadsheet — selecting cells, switching sheets, editing data, and structural changes like inserting rows or columns.

All events include a type discriminator and a timestamp (Unix milliseconds). Operation events also include sheetName.

import { SpreadsheetEditor } from "@grid-is/editor-react";
import type { EditorEvent } from "@grid-is/editor-react";
function App() {
const handleChange = (event: EditorEvent) => {
switch (event.type) {
case "selection-change":
console.log("Selected:", event.selection);
break;
case "sheet-change":
console.log("Switched to:", event.sheetName);
break;
case "write-cell":
console.log("Wrote:", event.cellId, "=", event.value);
break;
// ... handle other event types
}
};
return <SpreadsheetEditor model={model} onChange={handleChange} />;
}
TypeKey fieldsDescription
selection-changeselectionUser moved selection to a different cell or range
sheet-changesheetName, previousSheetNameUser switched sheet tabs
TypeKey fieldsDescription
write-cellcellId, valueCell value changed
clear-cellsrangeCell contents cleared
format-cellsrange, formatCell formatting changed
pasterangeContent pasted
fillsourceRange, targetRangeCells filled (drag to fill)
TypeKey fieldsDescription
insert-rowrow, directionRow inserted above or below
insert-columncolumn, directionColumn inserted left or right
delete-rowsstartRow, countRows deleted
delete-columnsstartColumn, countColumns deleted
resize-rowrow, heightRow height changed
resize-columncolumn, widthColumn width changed
TypeKey fieldsDescription
move-cellsfromRange, toRangeCells moved
move-rowsfromRange, toRangeRows moved
move-columnsfromRange, toRangeColumns moved
TypeKey fieldsDescription
add-sheetsheetNameNew sheet added
delete-sheetsheetNameSheet deleted
rename-sheetoldName, newNameSheet renamed
// Navigation events only (selection + sheet switching)
type ViewerEvent = SelectionChangeEvent | SheetChangeEvent;
// All events including data operations
type EditorEvent = ViewerEvent | WriteCellEvent | PasteEvent | ClearCellsEvent | ...;