We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

React Spreadsheet control - how to get current JSON data for the whole Spreadsheet in beforeSave?


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?

3 Replies 1 reply marked as answer

SP Sangeetha Priya Murugan Syncfusion Team January 9, 2023 10:00 AM UTC

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.




To get the spreadsheet's whole data into a key value object. Please refer to the below link.



Could you please check the above link and get back to us if you need any further assistance on this?

Marked as answer

DS Dawid Sibinski January 9, 2023 01:21 PM UTC

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!

SP Sangeetha Priya Murugan Syncfusion Team January 11, 2023 12:11 PM UTC

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.

Live Chat Icon For mobile
Up arrow icon