gregnb / mui-datatables

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

Hide the column of expandable buttons #1640

Closed wenscl closed 3 years ago

wenscl commented 3 years ago

Is there a way to hide the column of expandable buttons?

patorjk commented 3 years ago

I'm assuming you want to expand the rows on click but not see the expand button? If so, one option is to override the ExpandButton component and just have it render a null object. You can see how to override the expand button in this example:

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

You'd also need to set the expandableRowsHeader option to false, so that the Expand All header wasn't visible.

wenscl commented 3 years ago

I load the table with all rows expanded so i don't need that column. I tried your solution but it only hides the buttons, the column is still showing.

image

patorjk commented 3 years ago

Looks the problem is the "MuiTableCell-paddingCheckbox" class, which is adding padding and width to the cell. You can get around this by overriding that class. Here's an example that shows how to do that:

https://codesandbox.io/s/muidatatables-custom-toolbar-forked-mjmnp?file=/index.js

wenscl commented 3 years ago

Thanks! I set display=none to that class and it worked.