Posted 16 June 2020, 9:19 pm EST
Hello,
I could not find it, is it possible to protect the sheet from being deleted (renamed, etc.)?
Forums Home / Spread / SpreadJS
Posted by: ltetemadze on 16 June 2020, 9:19 pm EST
Posted 16 June 2020, 9:19 pm EST
Hello,
I could not find it, is it possible to protect the sheet from being deleted (renamed, etc.)?
Posted 18 June 2020, 12:23 am EST
Hi,
SJS provides SheetChanging, SheetNameChanging, SheetMoving Events that could be used for preventing the changes in sheet for example:
For preventing the name changing action on the sheet you may use SheetNameChanging Events please refer to the following code snippet.
spread.bind(GC.Spread.Sheets.Events.SheetNameChanging, (e, args) => {
args.cancel = true;
});
Similarly, for preventing the delete Action on the sheet you may use sheetChanging events and cancel the event if the action is deleteSheet or you could protect the sheet that will also disable the delete action on the sheet. Please refer to the following code snippet:
spread.bind(GC.Spread.Sheets.Events.SheetChanging, (e, args) => {
if (args.propertyName === "deleteSheet") {
args.cancel = true;
}
});
You may also refer to the following sample which demonstrates the same:
https://codesandbox.io/s/hungry-swirles-41wze?file=/src/index.js
API References:
• SheetChanging: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Events~SheetChanging_EV.html
• SheetNameChanging: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Events~SheetNameChanging_EV.html
• SheetMoving: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Events~SheetMoving_EV.html
Regards