Closed pellejacobs closed 5 years ago
This would also be useful for me too.
Seems like a duplicate of this issue: https://github.com/gregnb/mui-datatables/issues/549. If you follow up there with a proposal for the behavior, we can come up with a PR plan.
Hi Gabriel, Thanks for you reply. There's a little difference with the issue you linked: it seems there the main idea is to make the expandability optional. However, the rows would still be controlled by the MUIDataTable component. On the other hand, if you would allow for expandable rows to be controlled with props, you should be able to implement the behaviour mentioned in the issue. Is that what you would suggest?
You're right, they're not identical issues. I'm open to a PR that allows this functionality. Just be aware that the library is transitioning to be entirely controller via props, so the more of that type of functionality the library accepts, the more burden there will be on the developer to keep the state up-to-date. This can be made easier, but not without a major refactor, so there's a long term/short term tension regarding improvements like these.
@pellejacobs New option was added to allow setting the expanded state of expandable rows in 2.7.0
. Let me know if this solves your use case.
@gabrielliwerant , I just tested in in a codesandbox, use the expandable rows example code , works like a charm.
Really impressive, thanks!
Currently, expandedRows is uncontrolled, allowing rows only to be expanded using the built-in dropdown. This functionality is perfect is most scenarios but some use cases require a bit more customisation. Eg. by having the first row expanded by default, or by having triggers outside the table expand and collapse rows.
Expected Behavior
It'd be great to have an additional, optional prop
expandedRows
that takes an array of indices of the expanded rows, or maybe an array of{ dataIndex, index }
objects. When this prop changes, the rows will expand / collapse.If this prop is not assigned, the current controlled behaviour takes over and the expandedRow state is stored in state of the MUIDataTable.
Current Behavior
There is currently no way to control the expanded state of rows outside the table.