本帖最后由 Joestar.Xu 于 2024-7-26 15:05 编辑
楼主可以试试这段代码
- var designer = new GC.Spread.Sheets.Designer.Designer(
- document.getElementById("designerHost")
- );
- var spread = designer.getWorkbook();
- let oldOpenMenu = spread.contextMenu.onOpenMenu;
- //let oldOpenMenuBind = spread.contextMenu.onOpenMenu.bind(spread.contextMenu);
- spread.contextMenu.onOpenMenu = function (
- menuData,
- itemsDataForShown,
- hitInfo,
- workbook
- ) {
- let sheetTab = workbook.getActiveSheetTab();
- if (
- hitInfo &&
- hitInfo.hasOwnProperty("tabStripHitInfo") &&
- sheetTab instanceof GC.Spread.Report.ReportSheet &&
- sheetTab.renderMode() === "Preview"
- ) {
- return false;
- }
- oldOpenMenu.call(
- spread.contextMenu,
- menuData,
- itemsDataForShown,
- hitInfo,
- workbook
- );
- // oldOpenMenu.apply(spread.contextMenu, [menuData, itemsDataForShown, hitInfo, workbook]);
- // oldOpenMenuBind(menuData, itemsDataForShown, hitInfo, workbook);
- };
复制代码 |