Posted 11 April 2025, 3:24 am EST
It would be helpful to have a disableProtection method on the designer config it would save everyone hours and hours of repeating the same code by figuring it out themselves . Just the adding code here for someone else to use.
If developers wrote it , we will rely on ids and labels that you may change and it might break our application
variable **spreadSheet ** is instance of GC.Spread.Sheets.Workbook
variable designerConfigis GC.Spread.Sheets.Designer.DefaultConfig
Removing protect and unprotect options from the CellsFormat button group pf the homeRibbon
const homeMenu = designerConfig.ribbon.find(s => s.id === "home");
const cellsButtonGroup = homeRibbon.buttonGroups.find(s => s.label === "Cells");
const cellsFormatButtonGroup = cellsButtonGroup.commandGroup.children.find(s => s.command === "cellsFormat");
const unprotectIndex = cellsFormatButtonGroup.children.indexOf('unProtectSheet');
if (unprotectIndex > -1) {
cellsFormatButtonGroup.children.splice(unprotectIndex, 1);
}
const protectIndex = cellsFormatButtonGroup.children.indexOf('"cellFormatProtectSheet"');
if(protectIndex > -1) {
cellsFormatButtonGroup.children.splice(protectIndex, 1);
}
**Removing Sheet settings from the Settings Ribbon **,
const settingsRibbon = config.ribbon.find(s => s.id === "settings");
const sheetSettingsIndex = settingsRibbon.buttonGroups.findIndex(s => s.label === "Sheet Settings");
if (sheetSettingsIndex > -1) {
settingsRibbon.buttonGroups.splice(sheetSettingsIndex, 1);
}
May be on the workbook it is for developers to do as they might want to do other things on open menu of the context menu
Removing unprotect option from the context menu if sheet is set to be protected
spreadSheet.contextMenu.onOpenMenu = function (menuData, itemsDataForShown, hitTest) {
oldOpenMenu.apply(this, arguments);
if (hitTest.tabStripHitInfo && hitTest.tabStripHitInfo.sheetTab) {
spreadSheet.sheets.forEach(sheet => {
if (sheet.options.isProtected) {
let index = itemsDataForShown.findIndex((item) => item.name === "unprotectSheet");
itemsDataForShown.splice(index, 1);
}
});
}
}