Skip to content

Revert and restore your changes, using the undo and redo features.

Overview

This feature allows you to revert changes made in the data grid. It is very useful in a normal day-to-day routine, especially when the change is unintentional. This feature stacks the changes made with the user interface of the grid. Modifications done programmatically are omitted.

The basic methods are undo() and redo(). The undo() method rolls back the last performed action, and the redo() method restores it.

This feature is provided by the UndoRedo plugin, and is enabled by default.

Basic demo

Make some changes to the grid below and the use the Ctrl/Cmd+Z command to redo the previous state. Then, use Ctrl/Cmd+Y (or Ctrl/Cmd+Shift+Z) to restore it.

JavaScript
import Handsontable from 'handsontable/base';
import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.
registerAllModules();
const container = document.querySelector('#example');
new Handsontable(container, {
data: [
['A1', 'B1', 'C1', 'D1', 'E1'],
['A2', 'B2', 'C2', 'D2', 'E2'],
['A3', 'B3', 'C3', 'D3', 'E3'],
['A4', 'B4', 'C4', 'D4', 'E4'],
['A5', 'B5', 'C5', 'D5', 'E5'],
['A6', 'B6', 'C6', 'D6', 'E6'],
['A7', 'B7', 'C7', 'D7', 'E7'],
['A8', 'B8', 'C8', 'D8', 'E8'],
['A9', 'B9', 'C9', 'D9', 'E9'],
],
rowHeaders: true,
colHeaders: true,
stretchH: 'all',
height: 'auto',
autoWrapRow: true,
autoWrapCol: true,
licenseKey: 'non-commercial-and-evaluation',
});
TypeScript
import Handsontable from 'handsontable/base';
import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.
registerAllModules();
const container = document.querySelector('#example')!;
new Handsontable(container, {
data: [
['A1', 'B1', 'C1', 'D1', 'E1'],
['A2', 'B2', 'C2', 'D2', 'E2'],
['A3', 'B3', 'C3', 'D3', 'E3'],
['A4', 'B4', 'C4', 'D4', 'E4'],
['A5', 'B5', 'C5', 'D5', 'E5'],
['A6', 'B6', 'C6', 'D6', 'E6'],
['A7', 'B7', 'C7', 'D7', 'E7'],
['A8', 'B8', 'C8', 'D8', 'E8'],
['A9', 'B9', 'C9', 'D9', 'E9'],
],
rowHeaders: true,
colHeaders: true,
stretchH: 'all',
height: 'auto',
autoWrapRow: true,
autoWrapCol: true,
licenseKey: 'non-commercial-and-evaluation',
});

Known limitations

Not all user-triggered actions are recorded in the undo-and-redo history. Here’s the list of all unsupported features:

WindowsmacOSActionExcelSheets
Ctrl+ZCmd+ZUndo the last action
Ctrl+YCmd+YRedo the last action
Ctrl+Shift+ZCmd+Shift+ZRedo the last action

Configuration options

Core methods

Hooks

Plugins