您可以参考附件的demo:选择要删除的行数,按下 F4 ,即可实现删除该行
核心代码:
- var command = {
- canUndo: true,
- execute: function (context, options, isUndo) {
- var Commands = GC.Spread.Sheets.Commands;
- if (isUndo) {
- Commands.undoTransaction(context, options);
- return true;
- } else {
- Commands.startTransaction(context, options);
- var sheet = context.getSheetFromName(options.sheetName);
-
- var row = sheet.getSelections()[0].row;
- var rowCount = sheet.getSelections()[0].rowCount;
- sheet.deleteRows(row,rowCount);
-
- Commands.endTransaction(context, options);
- return true;
- }
- }
- };
- spread.commandManager().register("deleteColumns", command);
- //设置F4快捷键
- spread.commandManager().setShortcutKey(
- "deleteColumns", 115, false, false, false, false
- );
复制代码
|
|