react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Tree View with Sorting

Open kgf2018 opened this issue 6 years ago • 2 comments

Hello,

Thanks for the wonderful react-data-grid component.

I'm trying to get the react-data-grid component to have the tree view function with sort functionality. However, after expanding a grouped row, an exception is thrown as you can see from the codesandbox fork here : https://codesandbox.io/s/rdg-tree-view-yu4zs?file=/src/index.js

The example is based on the basic tree and sort functionality examples of react-data-grid (https://adazzle.github.io/react-data-grid/docs/examples/simple-grid)

Requesting help or an example on how to enable sorting on the tree view.

Thank You.

The error is as below.

eval
/src/index.js:100:24
   97 | };
   98 | const onCellExpand = args => ({ rows, expandedRows }) => {
   99 |   const rowKey = args.rowData.id;
> 100 |   const rowIndex = rows.indexOf(args.rowData);
      |                        ^
  101 |   const subRows = args.expandArgs.children;
  102 |   if (expandedRows && !expandedRows[rowKey]) {
  103 |     expandedRows[rowKey] = true;

kgf2018 avatar May 12 '20 09:05 kgf2018

You have the error, because setState hook doesn't know anything about "rows". Only in the "setRows" hook you know about rows.

emsi-iggy avatar May 12 '20 19:05 emsi-iggy

Closing this as we do not support previous versions of react-data-grid anymore. Please try the latest version, currently 7.0.0-beta.2. If you still run into issues with the latest version, please open a new issue.

nstepien avatar Aug 17 '21 17:08 nstepien