Catching add/delete sheet when triggered programatically

Posted by: lpagliaro on 1 February 2021, 4:41 pm EST

    • Post Options:
    • Link

    Posted 1 February 2021, 4:41 pm EST

    Hi! We have a binding over the SheetChanged event, but when adding or removing a sheet programatically the event is not triggered. Is there a way to do it?

  • Posted 3 February 2021, 7:48 am EST

    Hi Luis,

    ​The SpreadJS only provide events for the user activity. Since the adding/removing sheets by code is not something that could be done by the end-user that is why SJS does not fire the SheetChanged event. what you could do is make custom events and emit them after you add/remove the sheet. Please refer to the following code snippet and attached the same that demonstrates the same.

    
     //add sheet
        spread.addSheet(0, new GC.Spread.Sheets.Worksheet("My Sheet"));
        //Emit The event
        publish("SheetChangedByCode", {
          spread: spread,
          index: 0,
          propertyName: "addSheet"
        });
    
    

    sample: https://codesandbox.io/s/compassionate-curie-yo29r

    Regards

    Avinash

Need extra support?

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

Learn More

Forum Channels