Override default "add sheet" behavior

Posted by: daniel on 30 December 2020, 3:37 am EST

    • Post Options:
    • Link

    Posted 30 December 2020, 3:37 am EST

    Hi there,

    Is it possible to have the “+” button that adds sheets on the tab strip call a custom function instead of immediately adding a new sheet?

    If not, is it possible to add a custom button to the tab strip that could be used to trigger a custom function?

  • Posted 30 December 2020, 9:24 pm EST

    Hi,

    You may use SheetChanging Event for the required functionality. Please refer to the following code snippet and attached sample that demonstrates the same.

    
    spread.bind(GC.Spread.Sheets.Events.SheetChanging, (e, args) => {
        if (args.propertyName === "insertSheet") {
          alert("sheetInserting");
          //call for custom function here
          //if dont want add sheet just make args.cancel =true
    
        }
    
    

    sample: https://codesandbox.io/s/kind-meitner-rh0m1?file=/src/index.js

    Regards

    Avinash

  • Posted 4 January 2021, 2:32 am EST

    HI Avinash,

    The “args.cancel = true” line seems to be exactly what we need, but we tried it and it didn’t work. The sheets still get added. Is there anything else we need to do besides just put this line of code?

  • Posted 4 January 2021, 7:54 pm EST - Updated 3 October 2022, 1:01 am EST

    Hi Daniel,

    We are sorry but we are unable to replicate the issue at our end. Please refer to the following gif of our observation and the sample that we used for testing and let us know if we have missed any steps.

    sample: https://codesandbox.io/s/affectionate-easley-hkvuz

    Regards

    Avinash

  • Posted 6 January 2021, 3:37 am EST

    The solution worked perfectly, sorry for the alarm. We were working in the SheetChanged event vs. the SheetChanging event :man_facepalming:t2:

    Thank you very much!

  • Posted 6 January 2021, 6:43 pm EST

    Hi Daniel,

    We are glad to know that the issue has been fixed at your end. Please feel free to revert back if you have any further queries regarding this issue in future.

    Regards

    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels