How to correctly fill rows and columns using React datasheet?

Asked

Viewed 52 times

0

I’m using the react datasheet to export and import data by pasting into my application tables. I expect all columns and rows I copy to be pasted normally. However, only one row and two columns are being filled in. I tried using parsePaste also, but I can’t solve this problem with him.

Follow the code excerpt:

return (
    <Datasheet
      data={grid}
      loading={loading}
      title="Impostos"
      valueRenderer={cell => cell.value}
      onContextMenu={(e, cell) => (cell.readOnly ? e.preventDefault() : null)}
      onCellsChanged={changes => {
        changes.forEach(({ row, col, value }) => {
          grid[row][col] = { ...grid[row][col], value };
        });

        const gridWithoutEmptyRows = grid.filter(rowHasValues);
        if (lastRowHasAnyValue(gridWithoutEmptyRows)) {
          pushNewLineToEnd(gridWithoutEmptyRows, {
            [originColumn]: {
              value: '',
              dataEditor: Selector,
              valueViewer: ValueViewer,
            },
          });
        }
        setGrid(gridWithoutEmptyRows);

        const dataFromGrid = gridWithoutEmptyRows.slice(1);
        dispatch(setTaxes(mapGridToTaxes(dataFromGrid)));
      }}
      parsePaste={strings => {
        const rows = strings.split('\n\r');
        const table = rows.map(row => {
          return row.split('');
        });
        debugger;

        return table;
      }}
    />   );
};

All rows and columns must be filled in, but what I’m getting is this:

inserir a descrição da imagem aqui

  • what was to appear ...

  • @novic all columns and rows should be filled in because I copied three columns and three rows of an excel sheet

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.