How do I append new row's data with `fetch`?

Tags: #<Tag:0x00007f8b1df4e048>

Greetings Aleksandra! I hope you’re doing well.

I’ve been trying to append new row’s data with fetch for days but couldn’t find any working solution. I did try my best to search through stackoverflow and this forum for potential solutions. If this is already asked please forgive me.

I’ve looked into Inserting a row with values on button click but couldn’t modify to suit my particular situation.

Below is the minimal code to describe the problem:

<script>
    const hot = new Handsontable(container, {
        rowHeaders: true,
        colHeaders: true,
    });

    // Adding first row data
    fetch('http://localhost:3005/00700_Data.txt')
        .then(res => res.text())
        .then(res => res.split(","))
        .then(Data => hot.updateSettings({
            data: [Data]
        }));

    // Question: how to append to second row, instead of overriding first row's data?
    fetch('http://localhost:3005/00701_Data.txt')
        .then(res => res.text())
        .then(res => res.split(","))
        .then(Data => hot.updateSettings({
            data: [Data]
        }));
</script>

Any pointer or help is much appreciated. Thank you!

Hi @BlueVelvet

we do not have any example with server-side data change besides this one https://handsontable.com/docs/8.1.0/tutorial-load-and-save.html. But in theory, you can do two things

  • refresh all the data with the thing that you use updateSettings({ data: [Data] } ) or loadData() (Core method)
  • change a single via via setDataAtCell method.
1 Like