Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to expand only some rows on the basis of some condition, hide/remove expandable icon of some rows #1446

Open
007AMAN007 opened this issue Jul 28, 2020 · 8 comments

Comments

@007AMAN007
Copy link

I am using "expandableRows". I want to expand some rows on the basis of some condition. I can achieve this with the help of "isRowExpandable". But it is not helping me to hide/remove expandable icon. I want to hide/remove expandable icon of some rows.

@007AMAN007
Copy link
Author

Hi @patorjk .

See this example https://codesandbox.io/s/dreamy-meadow-oghwd

I want to hide "Expandable icon" if there is no "inner row". Like row with name "John Walshs". Is single row. No row inside it. So I want to hide "Expandable icon" of it.

Also one more issue here, if am hiding column of table from "view columns" feature, I want to hide column of "inner row" as well. Can we do this?

@patorjk
Copy link
Collaborator

patorjk commented Aug 8, 2020

Added a fix for this in version 3.4.0. You can now override the ExpandButton component. Example: https://github.com/gregnb/mui-datatables/blob/master/examples/expandable-rows/index.js#L119

@007AMAN007
Copy link
Author

Thanks @patorjk

Thanks for providing solution quickly. It's working fine. Thanks

@Mr777Nick
Copy link

Mr777Nick commented Sep 8, 2020

Added a fix for this in version 3.4.0. You can now override the ExpandButton component. Example: https://github.com/gregnb/mui-datatables/blob/master/examples/expandable-rows/index.js#L119

Hi, thanks for this! So I've tried this solution, but there's something that I can't do with it.

Here's the problem, I need to hide the expand button on specific condition, I need to see if the value on a column is null, for example, then hide the expand button if it is. As of now, I'm unable to do that because the props to override the ExpandButton doesn't have the value for the column I'm refering to. There are only isHeaderCell, expandedRows, expandableRowsHeader, areAllRowsExpanded, onExpand inside the props.

I can just use the index to set isRowExpandable as false, but then the index is messed up if I filter or sort the table by clicking the table header. Another way that I can think is if I pass the rowData to isRowExpandable, but I can't seem to pass rowData, I can only pass dataIndex and expandedRows.

Do you know a workaround for this? Thank you!

@ReangeloJ
Copy link

I have the same issue. I had a function which returns the indexes based on some condition, of my original data-source for which I would like the rows to be expandable. However when I filter, it changes the table internal data-source not my original data-source so the index references are wrong. Is there a way to pass the tablerowData to the isRowExpandable method?

@kpalumbohp
Copy link

I know this is a couple of years old but I am also having this issue where I'm trying to hide the dropdown based on the rowData but there is no way to access the rowData when using the solution above. Is there a workaround for this?

@ReangeloJ
Copy link

I know this is a couple of years old but I am also having this issue where I'm trying to hide the dropdown based on the rowData but there is no way to access the rowData when using the solution above. Is there a workaround for this?

I would try using React-Table. It is headless so you can style it however you want.

@stone2dbone
Copy link

It's been 7 months since this question was last asked: Has a solution been developed where one can use a value from rowData to remove the expandable icon/disable expandable rows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants