您好,请参考一下代码重写clearContents命令:
- let designerConfig = JSON.parse(
- JSON.stringify(GC.Spread.Sheets.Designer.DefaultConfig)
- );
- designerConfig.contextMenu[29] = "gc.spread.contextMenu.clearContents1";
- let newCommand = GC.Spread.Sheets.Designer.getCommand(
- GC.Spread.Sheets.Designer.CommandNames.ClearContents
- );
- console.log(newCommand);
- if (newCommand) {
- newCommand.commandName = "gc.spread.contextMenu.clearContents1";
- newCommand.execute = function (context, propertyName, args) {
- console.log("clearContents");
- // do something
- var spread = context.getWorkbook();
- spread.commandManager().execute({
- cmd: "gc.spread.contextMenu.clearContents",
- activeCol: args.activeCol,
- activeRow: args.activeRow,
- commandOptions: args.commandOptions,
- itemName: "gc.spread.contextMenu.clearContents",
- selections: args.selections,
- sheetName: args.sheetName,
- tableName: args.tableName,
- });
- // do something
- spread.getActiveSheet().repaint();
- };
- }
- designerConfig.commandMap = {};
- designerConfig.commandMap["gc.spread.contextMenu.clearContents1"] =
- newCommand;
- let designer = new GC.Spread.Sheets.Designer.Designer(
- "gc-designer-container",
- designerConfig
- );
复制代码 |