Skip to main content

canUndo()

pro version only

This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) package.

checks whether an action within the Grid history can be undone

canUndo(): boolean;

Returns:

Returns true if the history contains actions and the module is not disabled.

Example

// The example shows checking whether undo is possible after removing a row
const grid = new dhx.Grid("grid_container", {
columns: [
{ id: "name", header: [{ text: "Name" }] },
{ id: "value", header: [{ text: "Value" }] },
],
data: [
{ id: "1", name: "Item 1", value: 10 },
],
history: true
});

// removing a row
const removedItem = { id: "1", name: "Item 1", value: 10 };
grid.data.remove("1");
grid.history.add({
type: "remove",
batch: [{ ...removedItem }],
});

// checking
if (grid.history.canUndo()) {
console.log("Undo is possible");
grid.history.undo();
}

Change log:

added in v9.2