Spread.Sheets Documentation
Using Undo and Redo

You can use Ctrl + Z to undo an action in the widget. You can then use Ctrl + Y to redo the action you canceled.

You can undo the following types of actions:

The following actions do not respond to Ctrl + Z:

You can prevent or allow the undo action in code with the options.allowUndo property.

Using Code

This example sets the options.allowUndo property and specifies an action.

JavaScript
Copy Code
spread.options.allowUndo = true;
spread.commandManager().execute({cmd: "outlineRow", sheetName: activeSheet.name(), index: 3, count: 5});

The following code can be used to undo or redo an action.

JavaScript
Copy Code

$(function () {
            var spread = new GC.Spread.Sheets.Workbook($("#ss")[0]);
            var activeSheet = spread.getActiveSheet();
            spread.commandManager().execute({cmd: "outlineRow", sheetName: activeSheet.name(), index: 3, count: 5});
            $("#button1").click(function () {
                if(spread.undoManager().canUndo()){
                    spread.undoManager().undo();
                }
            });

            $("#button2").click(function () {
                if(spread.undoManager().canRedo()){
                    spread.undoManager().redo();
                }
            });
        })

See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Send comments on this topic.