gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.7k stars 931 forks source link

Expandable row is not working for me. #352

Closed rohitjogson closed 5 years ago

rohitjogson commented 5 years ago

I just add

  1. expandableRows
  2. renderExpandableRow

in option as you shown in example but its not working and i need this urgently.

gregnb commented 5 years ago

Please share how you are using the library and I can take a look

rahulgupta-mmr commented 5 years ago

I just add ...

@rohitjogson

Make sure your “options“ variable is defined in the render() function.

I removed the input arguments and did something basic to test functionality:

image

You can also use a map function for JSON data in this case as well:

image

Sent with GitHawk

rahulgupta-mmr commented 5 years ago

@gregnb No matter what I define in my renderExpandableRow() method, I get the same child rows repeated for each expandable row. For example, if I write:

image

For every one of my expandable rows, my child row shows a “Hi” cell.

I have unique child data for all of my parent rows. How can I go about implementing that?

Thanks

Sent with GitHawk

gregnb commented 5 years ago

@rahulgupta97 Please take a look at this example here:

https://github.com/gregnb/mui-datatables/blob/master/examples/expandable-rows/index.js#L84

You will see there are two arguments passed. rowData and rowMeta which will provide you with the data for that row

      renderExpandableRow: (rowData, rowMeta) => {
      }
rahulgupta-mmr commented 5 years ago

@rahulgupta97 Please take a look at this example here: ...

@gregnb

Ah, got it. Thanks!

Sent with GitHawk

simonkaspersen commented 5 years ago

Is it any way to return the whole row item in rowData? Not all metadata is displayed in the table, but want to show them once the row is expanded.

simonkaspersen commented 5 years ago

It looks like data[rowMeta.dataIndex] returns correct item.