When SubComponent is specified ReactTable shows collapse button for all rows in a table.
Is it possible to control the visibility of this button (i.e. if for some rows subcomponent is not available).
Thanks!
This is really an implementation question but it is possible. You need to have some condition in your row that would allow you to determine if the toggle should be shown or not and then would have to provide an Expander component replacement that checked the condition.
Here is an example (which also has a custom expander in a different column - but you don't have to do that) which conditionally shows the expander based on some content in the row.
https://codesandbox.io/s/pjmk93281j
I'll close this for now. If you need further help you should probably go to the react-table Slack channel (badge at the top of the README in the doco) as the github issue are really for bugs in the code and are not regularly monitored. Thanks.
Great example @gary-menzel.
My issue with having the SubComponent prop on <ReactTable /> is that any array of columns passed will have the SubComponent column added automatically. Even if your array of columns does not include expander: true.
I don't know if it would be too difficult to require users to explicitly include the expander property in their columns array.
I'm working on a workaround for this, will post if I succeed.
Okay, funny enough five minutes after posting that I found a workaround.
If you are using dynamic columns, some of which you do not want to show an "expander" column, prepend your columns array with this object
{
expander: true,
show: false,
}
Is there a solution to use a regular react-table expander (in first column) with same conditions that in example (by @gary-menzel)?
and not to create a separate column for this
Thanks!
Most helpful comment
This is really an implementation question but it is possible. You need to have some condition in your row that would allow you to determine if the toggle should be shown or not and then would have to provide an Expander component replacement that checked the condition.
Here is an example (which also has a custom expander in a different column - but you don't have to do that) which conditionally shows the expander based on some content in the row.
https://codesandbox.io/s/pjmk93281j
I'll close this for now. If you need further help you should probably go to the react-table Slack channel (badge at the top of the README in the doco) as the github issue are really for bugs in the code and are not regularly monitored. Thanks.