malte-wessel / react-custom-scrollbars

React scrollbars component
http://malte-wessel.github.io/react-custom-scrollbars/
MIT License
3.2k stars 577 forks source link

Scrollbars are rejected in MaterialUI Tables #158

Open lotusms opened 7 years ago

lotusms commented 7 years ago

When used in a material UI TableBody, it seems that MaterialUI rejects anything that may alter their table's architecture throught the DOM. Material UI forbids using anything other than TableHeader or TableBody as Table children, and any

inside of TableBody or Table Header (per HTML5 standars, this is not permitted either)

render as a div. Is there a way to assign Scrollbars to the TableBody without using the so that way the Table architecture is unchanged? Here is the code ` autoHide={false} style={ScrollBarsStyle}> {tableData.map( (row, index) => ( {row.name} {row.type} {row.owner} ))}
    </TableBody>` 

UPDATE The only way it can work is by adding the entire table inside the Scrollbars tags. But it disables the fixedHeader.

alexlukelevy commented 7 years ago

This can be accomplished by using two material-ui tables. One for the header and one for the rows.

<Table>
  <TableHeader>
  ...
  </TableHeader>
</Table>
<Scrollbars>
  <Table>
    <TableBody>
     ...
    </TableBody>
  </Table>
</Scrollbars>
lotusms commented 7 years ago

Yup! That did it! Thank you!

sarahshuffle commented 7 years ago

But what if you need the columns to be the same width?

alexlukelevy commented 7 years ago

Then give the both sets of columns a style property e.g. style={{ width: '10%' }}

justinmasse commented 7 years ago

Unideal solution. What if you want the header to be fixed on vertical scroll, however to scroll with the content on horizontal scroll.

edit: Seems the only way to go about it might be a modified version of what you have there combined with js to move the tablehead left or right.

carlosafw commented 5 years ago

How would the horizontal scrolling work in this case? @justinmasse did you get this to work?

TassosD commented 3 years ago

@justinmasse, @carlosafw just put both tables inside a horizontally scrollable div