As far as I can understand, you need to:
- Initially populate a Spreadsheet Sheet from a DataSource;
- Allow the user to upload a file and at this point alter only the data
in the Sheet bu t keep the DataSOurce configuration;
- Save the changed values / data to the server.
If this is the case, I am afraid, that the fromJSON()
method of the Spreadsheet is not an appropriate option. This is because it will simply remove the whole Sheets configuration from the widget (including the DataSource configured) and replace it with the data from the JSON. The same will happen if you use fromFile()
Therefore, there are two options that you could proceed with:
- As you suggested, you could destroy all the existing items in the Sheet DataSource and add the new once which you will get from the file. Note that the important part here is to call dataSource.sync()
as without it the changes won't be sent to the server.
- The other (and simpler) option would be to read the new data from file, send it with an AJAX call to the server
, repopulate it there and fter that has been done, call dataSource.read()
on the Sheet DataSource object to retrieve the new data from the server;