Skip to main content

beforeRedo

pro version only

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

triggered before redoing an action

Usage

type ActionType = "add" | "remove" | "removeAll" | "change";

interface IAction {
type: ActionType;
batch: IRow[];
inverse?: IAction;
}

beforeRedo: (action: IAction) => boolean | void;

Parameters:

The callback of the event is called with the following parameters:

action(object) the action object from the redo stack that contains the following properties:
  • type - (string) the type of action: "add", "remove", "removeAll", or "change"
  • batch - (array) an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)
  • inverse - (object) optional, the inverse action required for undoing (mandatory for the "change" and "removeAll" types, not required for other types)

Returns:

Returning false cancels the operation.

Example

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
});

grid.history.events.on("beforeRedo", (action) => {
if (action.type === "remove") {
console.log("Redoing removal is prohibited");
return false;
}
});

Change log:

added in v9.2