Autosave to Server

Posted by: m.holland-moritz on 15 December 2020, 2:15 am EST

    • Post Options:
    • Link

    Posted 15 December 2020, 2:15 am EST

    Hello everybody,

    while testing with SpreadJS Designer on the web I encountered a problem. When I reload the page all the data that was written to the spread is gone.

    In our case this is of course a very big problem, since all work we would have done would be gone. Because we sometimes work with very large files, some functions takes very long and then the browser gives an ‘Oops’ and everything is gone aswell.

    My question now: Is there a way to save the current state, whether on the server or locally in the cache / cookies? And does spreadJS offer a way to automatically recall this state after reload?

    I would be happy if you could help me with this.

    Best regards

  • Posted 16 December 2020, 12:10 am EST

    Hi,

    Regarding the Designer not showing any warning message when reloading

    We are able to replicate the issue at our end. hence we have forwarded it to the concerned team for further investigation. We will update you as soon as we get any information. The internal tracking Id for this issue will be SJS-6921.

    Regarding saving the state of workbook

    You may use a toJSON method for storing the state of the workbook. Please refer to the following code snippet and let us know if you face any issues.

    
    var spread = designer.getWorkbook();
    window.onbeforeunload = function () {
      localStorage.setItem(
        "spreadJSON",
        JSON.stringify(spread.toJSON({ includeBindingSource: true }))
      );
    };
    
    if (localStorage.getItem("spreadJSON") !== undefined) {
      spread.fromJSON(JSON.parse(localStorage.getItem("spreadJSON")));
    } 
    
    

    API refrences

    toJSON: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Workbook~toJSON.html?highlight=tojson%2C

    fromJSON: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Workbook~fromJSON.html?highlight=fromjson%2C

    Regards

    Avinash

Need extra support?

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

Learn More

Forum Channels