[React] Default data for new rows

Tags: #<Tag:0x00007efc6e342b70> #<Tag:0x00007efc6e342648>

Hi there!
I need to set the data for newly created rows (via context menu’s Insert row below option or by pasting more rows into the spreadsheet than currently is there). I need new rows to have formulas wit properly formatted formulas (e.g. for second row =A2+B2, for third =A3+B3) and text cells values (formulas from hyperformula). I’ve tried using dataSchema and the result is:

  • New rows (added by context menu or by pasting) are properly added but the formulas cells display the text representation of the formulas instead of calculated value. EXAMPLE

How can I make formulas to calculate the value with dataSchema? Is there another way of setting default value of newly created rows?

I am using React.

Hi @alojzy231

Yes, it is possible to do this with dataSchema. I’ve prepared a small example showing how it can be done: https://jsfiddle.net/handsoncode/6vzgnq5d/

The thing is, that in your implementation you are assigning the new formula just to the schema, so it’s not recalculated when you add the new row. The logic needs to be added to a hook that will also recalculate the table, like setDataAtCell in my example.

1 Like