本帖最后由 runergy 于 2022-6-27 11:06 编辑
如何不通过点击左键获取单元格,每次获取的都是上一次左键的菜单项
spread.suspendPaint();
this.SheetStyle();
sheet.setRowCount(0, GC.Spread.Sheets.SheetArea.viewport);
sheet.bind(GC.Spread.Sheets.Events.CellClick, function(sender, args) {
if (args.sheetArea === GC.Spread.Sheets.SheetArea.viewport) {
if(args.row==1){
//当为第二行时,加载菜单
spread.contextMenu.menuData = MenuDataViewportGraphical;
}
else{
spread.contextMenu.menuData=menuData
}
}
});
var menuData = spread.contextMenu.menuData;
MenuDataViewportEmpty = [];
MenuDataViewportGraphical = [];
MenuDataViewportDepartment = [];
//自定义新插入列
var custom_spread_Graphical_Insert = {
command: "custom.spread.Graphical.Insert",
text: "插入图形",
name: "custom.spread.Graphical.Insert",
iconClass: "",
workArea: "viewport"
}
//清空viewport的菜单项
menuData.forEach(function(item) {
if (item) {
if (item.workArea !== undefined) {
if (item.workArea.indexOf("viewport") !== -1) {
return;
}
}
MenuDataViewportEmpty.push(item);
MenuDataViewportGraphical.push(item);
MenuDataViewportDepartment.push(item);
}
});
MenuDataViewportGraphical.splice(menuData.length, 0, custom_spread_Graphical_Insert);
|