jspreadsheet / pro

Jspreadsheet Pro | The javascript spreadsheet
https://jspreadsheet.com/
15 stars 1 forks source link

Toggle all cells to be in 'edit/formula mode' #34

Closed MartinDawson closed 3 years ago

MartinDawson commented 3 years ago

Hi,

Is there a way to toggle all of the cells to be in edit mode and show the formulas of each cell?

Here's an example:

image

So the user can seen and edit the formulas one by one without having to click on each cell.

I took a look at your methods and there is no method to set each cell editable.

This is what I have tried:

const instance = jspreadsheet(spreadsheetRef.current, {
          data: chunkedData,
          cells: cellsFormatted,
        });

     cellKeysSorted.forEach((cellKey) => {
          const value = instance[cellKey];
          const cell = instance.getCell(cellKey);

          if (typeof value === "number") {
            instance.openEditor(cell);
          }
        });

This works for all cells apart from the last cell for some reason, however when I try to edit the cell an error gets thrown and it doesn't work:

index.js:15 Uncaught DOMException: Failed to execute 'appendChild' on 'Node': The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler?
    at Object._0x1702E.<computed>.<computed> [as createEditor] (webpack-internal:///./node_modules/jspreadsheet-pro/dist/index.js:19:327158)
    at Object._0x1C625.<computed> [as openEditor] (webpack-internal:///./node_modules/jspreadsheet-pro/dist/index.js:19:279243)
    at Object._0x173A3.<computed> [as openEditor] (webpack-internal:///./node_modules/jspreadsheet-pro/dist/index.js:19:71901)
    at HTMLDocument._0x1702E.<computed> (webpack-internal:///./node_modules/jspreadsheet-pro/dist/index.js:19:269778)
MartinDawson commented 3 years ago

Nevermind, fixed it by modifying innerHtml instead. Thanks