Override clearAndEditing;

Posted by: ngodinhvuluan on 19 April 2023, 2:34 pm EST

    • Post Options:
    • Link

    Posted 19 April 2023, 2:34 pm EST - Updated 19 April 2023, 2:37 pm EST

    I follow this code for clearAndEditing, but I found this command uses 2 params and don’t have params check Undo. How can i check clearAndEditing is Undo

    Note: I checking use backspace event from



    	let old = GC.Spread.Sheets.Commands.clipboardPaste.execute;
      	GC.Spread.Sheets.Commands.clipboardPaste.execute = function (spread, option, isUndo){
    		old.apply(this, arguments);
  • Posted 19 April 2023, 9:48 pm EST



    As I can understand, you want to find out if the clearAndEditing command can be performed in undo/redo.

    Please note that clearAndEditing command can not be undo and redo. You can get the clearAndEditing command object using spread.commandManager()[‘clearAndEditing’] statement. To know if the command is undoable/redoable, you can use command.canUndo() method.

    Please note that you can add custom command to command manager of spread. A custom command has two properties “canUndo” and “execute”. The “canUndo” properties specifies if a command can be undo/redo and “execute” method takes a function which is called when the command is executed.

    The execute function takes three arguments which are “context”, “options” and “isUndo”. “context” refers to the spread instance, “options” provides required values for the command to execute. “options” is different for different commands as they need different values. “isUndo” argument specifies if the command is performed in undo action or not.

    Please refer to the code snippet.

    let commandManager = spread.commandManager();

    let command = commandManager.clearAndEditing;


    Please let us know if have any doubts.

    Doc reference

    spread.commandManager(): https://www.grapecity.com/spreadjs/api/v16/classes/GC.Spread.Sheets.Workbook#commandmanager

    CommandManager class: https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Commands.CommandManager#class-commandmanager



  • Posted 19 April 2023, 9:55 pm EST

    I want to check the condition that allows paste and format style to call API!

    How can I keep paste command?

  • Posted 23 April 2023, 7:01 am EST


    We are sorry for the inconvenience caused. We are not able to understand your use case and what you are trying to achieve. Please explain about your use case.

    Also, you may provide us examples or a sample which demonstrates your use case scenario. It will help us in understanding your use case and providing solution for the same.



  • Posted 25 April 2023, 11:08 pm EST

    I cache source range by Ctrl+C by custom command but I want SpreadJS exec all my functions will execute next? How can do it

  • Posted 25 April 2023, 11:08 pm EST

    I cache source range by Ctrl+C by custom command but I want SpreadJS exec all my functions will execute next? How can do it

  • Posted 26 April 2023, 8:46 pm EST


    As per my understanding, you are storing the source range when Ctrl + C keys are pressed and then execute your functions.

    For this use case, you can bind an event handler to ClipboardChanging event to know when copy action is performed. In the handler of this event, you can execute your functions accordingly.

    Please refer to the code snippet.

    spread.bind(GC.Spread.Sheets.Events.ClipboardChanging, (event, args) => {
        let sourceRanges = args.ranges;
        // call to functions

    Please let us know if the provided solution does not match with your use case. Also, describe your use case with examples so that we could better understand and help you accordingly.



Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels