Skip to main content Skip to footer

Disable Protected Worksheet Messages from Designer Component

When a spreadsheet is protected, the Designer Component will display a dialog when attempting to interact with a locked cell: 

There are a couple of ways we can disable this dialog from showing up. We could unbind the InvalidOperation event from the Designer events, to start. This will prevent the dialog from displaying when performing any action that would trigger the InvalidOperation event, while still protecting the sheet(s) as expected. To do this, use the following code:

spread.unbind(GC.Spread.Sheets.Events.InvalidOperation + ".GC_Designer_Events");

We can also hide the dialog for specific operations, while still showing it for others. For example, we could hide the dialog for just the editProtected InvalidOperationType:

spread.bind(GC.Spread.Sheets.Events.InvalidOperation, function (sender, args) {
     if (args.invalidType != GC.Spread.Sheets.InvalidOperationType.editProtected) {
         // Perform Custom Actions
         GC.Spread.Sheets.Designer.showMessageBox(args.message, "SpreadJS Designer", GC.Spread.Sheets.Designer.MessageBoxIcon.warning)
     }
});

You can view a working sample here.

Tye Glenz