Replacing Cut/Paste

Posted by: adrien.corbin on 2 October 2018, 4:00 pm EST

    • Post Options:
    • Link

    Posted 2 October 2018, 4:00 pm EST

    Hi,

    We need make sure not to edit workbook styles with copy-paste and cut-paste.

    For this reason, as mentionned in the documentation we used following property to handle the paste case.

    
    worksheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
    

    The copy is not a problem because it does not modify the sources cells. However, the cut is problematic. To override the feature, I tried some modifier version of http://help.grapecity.com/spread/SpreadSheets11/webframe.html#sccopy.html

    
           spread.commandManager().register('cut', (args) => {
                let activeWorksheet = spread.getActiveSheet();
    
                spread.commandManager().execute({ cmd: 'copy' });
    
                for (let selection of activeWorksheet.getSelections()) {
                    activeWorksheet.clear(selection.row, 
                        selection.col, 
                        selection.rowCount, 
                        selection.colCount,
                        GC.Spread.Sheets.SheetArea.viewport,
                        GC.Spread.Sheets.StorageType.data);
                }
    
                this.isDirty = true;
            });
    
            // Remove original cut command
            spread.commandManager().setShortcutKey(undefined, GC.Spread.Commands.Key.x, true, false, false, false);
            spread.commandManager().setShortcutKey('cut', GC.Spread.Commands.Key.x, true, false, false, false);
    
    

    However, sending the copy command, does not seem to do the same thing as Ctrl-C. It does not copy the whole range and add the green dashed style to the selection.

    Am I using the copy command propertly to immitate Ctrl-C default behavior. To then delete the source range data and be able to paste the data as needed by the user.

    Thanks

  • Posted 3 October 2018, 7:13 am EST

    I found out that the commands need the sheet name to work. In my case it seem to work this way

     
    spread.commandManager().execute({ cmd: 'copy',  sheetName:activesheet.name()});
    
    

    I am not sure however if there is other parameters I need to provide. Is there docmentation for all commands parameters? I guessed the sheetName from various example but could not find information for other commands.

  • Posted 3 October 2018, 9:33 am EST

    Hello,

    Great, you can also take a look at the attached sample where I have shown how you can customize the behavior of Ctrl+X behavior.

    Thanks,

    Deepak SharmaSpreadJSCustomCtrlX.zip

Need extra support?

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

Learn More

Forum Channels