SMART datagrid v.1 > Examples

[ grids ver.1.3.0]   Back  Forward

Undo & Redo  Example

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

Grid - 1
rows
If change this value, the existing DataSet Uno list will be cleared.
If change this value, the existing Grid Undo list will be cleared.
If specify this property as true, the values of the selected area will be cleared by Delete key.
If specify this property as true, it will commit in cell unit in the updating row.
If specify this property as true, it will commit in cell unit in the appending row.

Clear Undo stack of the data set.
Clear Undo stack of the grid.

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. 

Code -1
    dataset.setUndoable(true);
    grid.setUndoable(true);

You can check whether Undoing or Redoing is possible through GridBase.onUndoStateChanged event. 

Code -2
    grdMain.onUndoStateChanged = function (grid, canUndo, canRedo) {
        document.getElementById('btnUndo').disabled = !canUndo;  
        document.getElementById('btnRedo').disabled = !canRedo;  
    };

View Source JSP 

See Also
Undoing Overview
GridBase.undoable
DataSet.undoable
GridBase.clearUndo
GridBase.onUndoStateChanged
EditOptions.erasable
EditOptions.updateByCell
EditOptions.insertByCell
Examples
Cell Editing
Edit Keys