BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hello,
I'd like to implement my own logic for saving the Spreadsheet document. I don't want to use `saveUrl`, but provide my own logic for saving, using React Spreadsheet component.
In order to do that, I provide a callback for `beforeSave` function:
which is implemented in the following way:
I need to get the current JSON data for the whole Spreadsheet there (see my comment in the code above). There's an API method saveAsJson(), but it triggers the save and beforeSave again recursively... I don't get why it would go to the API, by the way.
There are other functions there like `getData()`, but it requires providing some address. I want the whole JSONData.
I didn't find any other properties/functions on the spreadsheet editor ref instance. I assume the current JSON must be there on the client-side, because when using `saveUrl`, it's present in the controller:
Can you help me here, please?
Hi Dawid,
We suspect that you require the entire spreadsheet as JSON data based on the information you provided. So, we suggest you use the saveAsJson method in a button click or any other action instead of calling the beforeSave event because the beforeSave event is triggered while saving the spreadsheet. And we have done our import/export actions in ASP.Net only, not on the client side. So, if you need JSON data, you can use the saveAsJson method or the getData method. For more details, please refer to the below links.
https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#saveasjson
https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#getdata
To get the spreadsheet's whole data into a key value object. Please refer to the below link.
https://www.syncfusion.com/kb/13582/how-to-get-the-modified-data-as-key-value-pair-in-javascript-spreadsheet
Could you please check the above link and get back to us if you need any further assistance on this?
Hi Sangeetha,
thank you for your answer.
So basically, the `saveAsJson` function doesn't require server-side API... I see now that it works, and I can get the JSON object on promise resolution.
I thought it requires server-side call, because it also triggers the `beforeSave` callback.
It seems to do the job for now :)
Thanks for your help!
You're welcome, Dawid.
We are happy to hear that your issue has been resolved. Please get back to us if you need any further assistance.
NOTE: If that post is helpful, please consider accepting it as an answer so that other members can locate it more quickly.