Undo Extension
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.
Methods
The following methods are available via the gantt.ext.undo object:
Undo() / Redo()
- undo (): void - reverts the changes made in the gantt
gantt.ext.undo.undo();
- redo (): void - applies the reverted changes to the gantt once again
gantt.ext.undo.redo();
getUndoStack() / getRedoStack()
- getUndoStack (): UndoRedoAction[] - returns the stack of stored undo user actions
var stack = gantt.ext.undo.getUndoStack();
- getRedoStack (): UndoRedoAction[] - 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
setUndoStack() / setRedoStack()
- setUndoStack (stack): void - sets the stack of stored undo user actions
- stack - (UndoRedoAction[]) - the undo stack
gantt.ext.undo.setUndoStack(stack);
- setRedoStack (stack): void - sets the stack of stored redo user actions
- stack - (UndoRedoAction[]) - the redo stack
gantt.ext.undo.setRedoStack(stack);
clearUndoStack() / clearRedoStack()
- clearUndoStack (): void - clears the stack of stored undo commands
gantt.ext.undo.clearUndoStack();
- clearRedoStack (): void - clears the stack of stored redo commands
gantt.ext.undo.clearRedoStack();
saveState()
- 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".
gantt.ext.undo.saveState(1, "task");
gantt.ext.undo.saveState(1, "link");
Read the details in the Undoing/Redoing changes made from code article.
Back to top