The Undo object has a set of methods that allow you to undo/redo the made changes.
Read details about the Undo extension in the Undo/Redo Functionality article.
The following methods are available via the gantt.ext.undo object:
Undo() / Redo()
- undo (): void - reverts the changes made in the gantt
- redo (): void - applies the reverted changes to the gantt once again
getUndoStack() / getRedoStack()
- getUndoStack (): Array<object> - returns the stack of stored undo user actions
var stack = gantt.ext.undo.getUndoStack();
- getRedoStack (): Array<object> - returns the stack of stored redo user actions
var stack = gantt.ext.undo.getRedoStack();
The returned stack is an array of the undo user actions. Each user action contains a set of commands. A command is an object with the following attributes:
- type - (string) the type of a command: "add/remove/update"
- entity - (string) the type of the object which was changed: "task" or "link"
- value - (object) the changed task/link object
- oldValue - (object) the task/link object before changes
clearUndoStack() / clearRedoStack()
- clearUndoStack (): void - clears the stack of stored undo commands
- clearRedoStack (): void - clears the stack of stored redo commands
- saveState (id, entityType): boolean - saves the current state of a task/link before the changes are made
- id - (string | number) - the id of a task/link,
- type - (string) - the type of an entry for which the id is provided as the first argument.
Supported values: "task", "link".
Read the details in the Undoing/Redoing changes made from code article.
Back to top