您好,请参考以下代码尝试一下:
let designerConfig = JSON.parse(
JSON.stringify(GC.Spread.Sheets.Designer.DefaultConfig)
);
designerConfig.contextMenu[45] = "gc.spread.contextMenu.filter1";
let newCommand = GC.Spread.Sheets.Designer.getCommand(
GC.Spread.Sheets.Designer.CommandNames.Filter
);
console.log(newCommand);
if (newCommand) {
newCommand.commandName = "gc.spread.contextMenu.filter1";
newCommand.execute = function (context, propertyName, args) {
console.log("filter");
var spread = context.getWorkbook();
spread.commandManager().execute({
cmd: "gc.spread.contextMenu.filter",
activeCol: args.activeCol,
activeRow: args.activeRow,
commandOptions: args.commandOptions,
itemName: "gc.spread.contextMenu.filter",
selections: args.selections,
sheetName: args.sheetName,
tableName: args.tableName,
});
spread.getActiveSheet().repaint();
};
}
designerConfig.commandMap = {};
designerConfig.commandMap["gc.spread.contextMenu.filter1"] = newCommand;
let designer = new GC.Spread.Sheets.Designer.Designer(
"gc-designer-container",
designerConfig
); |