1

How can I implement row details and expanding/collapsing of custom details component using react-data-grid?

I have table of users and I want to be able to see user details after click/double click on the user row. Something like this: http://demos.telerik.com/kendo-ui/grid/detailtemplate . It is possible using this component?

kzg
  • 780
  • 9
  • 22
  • Are you using Bootstrap? Look into [`accordion toggling`](http://getbootstrap.com/javascript/#collapse-example-accordion) if so. – glhrmv Jun 09 '17 at 14:25
  • Well, not, I am not using bootstrap. But I can do sth like that accordion by myself, but how it will help me? How can I plug in it into the grid? As row custom renderer? Using `rowRenderer` and some events to expand/collapse details component? Like that: https://jsfiddle.net/f6mbnb8z/281/ ? – kzg Jun 09 '17 at 14:38

3 Answers3

1

There is an example for React similar to the jquery version of the Kendo grid. The idea is that you can now use React Components for the Details. For example you may place a another grid into the template Grid to get hierarchy.

class DetailComponent extends GridDetailRow {
render() {
    return (
        <Grid data={this.props.dataItem.details}>
        </Grid>
    );
}
}
// ...
// ...
 <Grid
       detail={DetailComponent}
       expandField="expanded"
       expandChange={this.expandChange}
 >
Xizario
  • 481
  • 2
  • 9
0

this is one of the maintainers of react-data-grid.

We consider the Kendo example to represent 2 different features:-

  • the ability to nest data in an expandable tree view
  • the ability to render any component (e.g. a sub-grid) as that child view

At the moment, we only have support for the former (see http://adazzle.github.io/react-data-grid/examples.html#/tree-view)

Nested Grids is something that is requested often, but unfortunately for now we do not currently support it. However, this may change in future.

HTH @jpdriver

-1

There are many ways to do, but the simplest maybe you can set the state of the component with the key of the cell clicked, and creating the component in a function, pass the value if should be collapsed or not, and return the collapsed or not component of that cell and render it.