Posted 6 June 2019, 4:18 am EST
Hi,
You could handle the contextMenu event and update the menuData for the context menu to customize the options shown. Please refer to the following code snippet and the attached same demonstrating the same:
spread.getHost().addEventListener('contextmenu', (e) => {
var offset = getCumulativeOffset(spread.getHost());
var htInfo = spread.hitTest(e.pageX - offset.left, e.pageY - offset.top);
if(!htInfo.tabStripHitInfo){
// not on tab strip
return;
}
if(htInfo.tabStripHitInfo.sheetTab.sheetName == "Sheet1"){
// disable delete option for Sheet1
setMenuDataDisable(spread.contextMenu.menuData, "gc.spread.deleteSheet", true);
}else{
// enable delete option
setMenuDataDisable(spread.contextMenu.menuData, "gc.spread.deleteSheet", false);
}
}, true);
function setMenuDataDisable(menuData, optionName, value){
// here we are only disabling the menu item, you may also remove the item from the menuData array to remove the item from the context menu
Array.prototype.forEach.call(menuData, function(data){
if(data.name == optionName){
data.disable = value;
}
});
}
~sharad
spreadSample.zip