Like common document editing applications, SMART datagrid provides the functions of Undoing and Redoing user input or data set updates.
If specify both GridBase.undoable and DataSet.undoable as true, the user can type "Ctrl+Z" and "Ctrl+Y" keys during the run time to return the update history or proceed again, and can call GridBase.undo and redo in the script.
(ctrl+Z, cmd+Z) (ctrl+Y, cmd+Y)
Data Updating can be happened in Grid and Data Set level. In the grid, it will happen when the user updates or appends the row, and in the data set, it will happen when the edited data in the grid is transferred to the data set or directly calls API function of the data set.
In order to enable Undo/Redo when edit the grid row, you can specify GridBase.undoable as true. And, in order to enable Undo/Redo in the data set level, you can specify DataSet.undoable as true. In most cases, you can specify both properties as true when provide Undo/Redo UI to the user.
dataset.setUndoable(true);
grid.setUndoable(true);
You can check whether Undoing or Redoing is possible through GridBase.onUndoStateChanged event.
grdMain.onUndoStateChanged = function (grid, canUndo, canRedo) {
document.getElementById('btnUndo').disabled = !canUndo;
document.getElementById('btnRedo').disabled = !canRedo;
};