Add function to designers import or new file option

Posted by: m.holland-moritz on 7 October 2021, 8:25 am EST

    • Post Options:
    • Link

    Posted 7 October 2021, 8:25 am EST

    Hello Team,

    I want to reset my own components as soon as my client opens a new or different workbook.

    Is there a way to add a custom function right after my clients uses the new file or import file option of the designer components?

    Regards

    Maik

  • Posted 8 October 2021, 4:49 am EST

    Hi,

    In the latest Designer component(v14.2.0) provide FileLoaded event. Please refer to the following code snippet and let me know if you face any issues.

    
    designer.bind(GC.Spread.Sheets.Designer.Events.FileLoaded, (event, data)=>{
      console.log("file has loaded");
     });
    
    

    API:

    FileLoaded: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJSDesigner~GC.Spread.Sheets.Designer.Events~FileLoaded_EV.html

  • Posted 11 October 2021, 4:02 am EST

    Hey,

    Thanks for that, but that won’t work for me, since i still need to work with the 14.0.1 Version of SpreadJS. The newest Version does break other custom stuff of my application.

    Is there another way to work with this?

    Regards

    Maik

  • Posted 12 October 2021, 12:46 am EST

    Hi,

    For the earlier version. You need to override the fromJSON method for the required functionality. Please refer to the following code snippet and let me know if you face any issues.

    
    let old = GC.Spread.Sheets.Workbook.prototype.fromJSON;
    
    GC.Spread.Sheets.Workbook.prototype.fromJSON = function() {
      old.apply(this, arguments);
      console.log("JSON has been changed");
      spread = designer.getWorkbook();
    };
    
    
  • Posted 12 October 2021, 2:26 am EST

    Worked for me!

    Thank you.

    Regards

    Maik

Need extra support?

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

Learn More

Forum Channels