您好,根据您提示的代码,我把项目代码更改为一下- let ind = 0
- designerConfig.contextMenu.forEach((item, index) => {
- if (item == 'gc.spread.contextMenu.clearContents') {
- ind = index
- }
- })
- designerConfig.contextMenu[ind] = "gc.spread.contextMenu.clearContents";
- let newCommand = GC.Spread.Sheets.Designer.getCommand(
- GC.Spread.Sheets.Designer.CommandNames.ClearContents
- );
- if (newCommand) {
- newCommand.commandName = "gc.spread.contextMenu.clearContents";
- newCommand.execute = function (context, propertyName, args) {
- console.log('123')
- var spread = context.getWorkbook();
- // 以下两行代码是 把显示的图片置空,实际上是修改单元格为文本类型
- var cellType = new GC.Spread.Sheets.CellTypes.Text();
- spread.getActiveSheet().setCellType(args.activeRow, args.activeCol, cellType);
- // 这里是清除单元格之前的操作
- 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,
- });
- // 清除单元格之后的操作
- spread.getActiveSheet().setValue(args.activeRow, args.activeCol, null);
- // this.sheet.setTag(args.row, args.col)
- // console.log(this.sheet.getTag(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport))
- spread.getActiveSheet().repaint();
- };
- }
- designerConfig.commandMap["gc.spread.contextMenu.clearContents"] =
- newCommand;
复制代码 但我发现,再使用“清除内容”的时候,console.log('123') 并没有打印。
请问是写法上还存在着什么问题吗?
另外,15版本上,我看 designerConfig.contextMenu[28]个是 gc.spread.contextMenu.clearContents1
而17斑斑上,designerConfig.contextMenu[30]个是 gc.spread.contextMenu.clearContents
请问 gc.spread.contextMenu.clearContents 与gc.spread.contextMenu.clearContents1,是有什么特殊含义吗?
|