Posted 13 November 2023, 11:05 am EST
Is there any way to generate an Event when creating a New workbook in the Designer using the File->New menu?
We have some actions we’d like to take upon creating a new workbook.
Forums Home / Spread / SpreadJS
Posted by: cory.engel on 13 November 2023, 11:05 am EST
Posted 13 November 2023, 11:05 am EST
Is there any way to generate an Event when creating a New workbook in the Designer using the File->New menu?
We have some actions we’d like to take upon creating a new workbook.
Posted 13 November 2023, 9:30 pm EST
Hi,
By default, there is no exposed event that is fired when the New Workbook is created from the file menu of the SpreadJS Designer.
As a workaround, you can add a mutation observer to the host element of the Workbook instance because when the new Workbook instance is created, the old Workbook instance is destroyed. With the mutation observer, you can find when the new instance is created and accordingly perform desired actions.
Please refer to the attached sample for more understanding.
If you continue to face the issue, please let us know.
Regards
Posted 14 November 2023, 6:39 am EST
I’ve used the Resize Observer before, but not the Mutation Observer. Thank you for the code. We’re using Vue3 and were able to almost copy/paste it in. Works nicely. We added a disconnect on the observer as well when unmounting the component.
Excellent support!