本帖最后由 鸳鸯配2024 于 2024-7-30 15:55 编辑
designer = new GCDesigner.Spread.Sheets.Designer.Designer('designer-container');
spread = designer.getWorkbook();
// 工具栏隐藏
designer.setData("isRibbonCollapse",true); // 功能生效
// let spread = GC.Spread.Sheets.Workbook
let sheet = spread.getActiveSheet();
spread.options.copyPasteHeaderOptions = GC.Spread.Sheets.CopyPasteHeaderOptions.allHeaders;
let spread5 = new GC.Spread.Sheets.Workbook(document.getElementById("designer-container"));
let oldF = spread5.contextMenu.onOpenMenu
spread5.contextMenu.onOpenMenu = function (menuData, itemsDataForShown, hitInfo, spread) {
itemsDataForShown.push({
text: "自定义右键菜单",
name: "customContextMenu",
command: "customCommand"
},{
text: "yustest",
name: "customContextMenu",
command: "customCommand"
})
// 在第二行不可用
let sel = spread.getActiveSheet().getSelections()[0]
if(sel.row == 1) {
itemsDataForShown.splice(0, itemsDataForShown.length)
}
oldF.apply(this, arguments)
}
spread5.commandManager().register("customCommand", {
canUndo: false,
execute: function (spread, options) {
console.log(arguments)
}
})
也没有报错,不知道是哪里的问题
https://demo.grapecity.com.cn/spreadjs/practice/menu/spread-add-custom-context-menu
我是直接直接把这个例子的代码拿过来的
|
|