question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scrollbars are rejected in MaterialUI Tables

See original GitHub issue

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 <div> inside of TableBody or Table Header (per HTML5 standars, this is not permitted either)

<Scrollbars> render as a div.

Is there a way to assign Scrollbars to the TableBody without using the <Scrollbars> so that way the Table architecture is unchanged?

Here is the code

    `<TableBody
	displayRowCheckbox={this.state.showCheckboxes}
	deselectOnClickaway={this.state.deselectOnClickaway}
	showRowHover={this.state.showRowHover}>
    	<Scrollbars  //not permitted. it renders as a <div>
    		autoHide={false}
    		style={ScrollBarsStyle}>
		{tableData.map( (row, index) => (
			<TableRow key={index}>
				<TableRowColumn>{row.name}</TableRowColumn>
				<TableRowColumn>{row.type}</TableRowColumn>
				<TableRowColumn>{row.owner}</TableRowColumn>
			</TableRow>
		))}
    	</Scrollbars>
    </TableBody>` 

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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

9reactions
alexlukelevycommented, May 19, 2017

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>
0reactions
TassosDcommented, Nov 26, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

material ui table horizontal scroll - Stack Overflow
On my CodeSandbox I get a horizontal scrollbar. Can you post a CodeSandbox with a version of your code that shows the problem?...
Read more >
Using React-Virtualized InfiniteLoader, Autosizer, and Table ...
Here are my two functions. In the parent component. getRowsFromServer = ({startIndex, stopIndex }) => { return new Promise((resolve, reject) => ...
Read more >
How to Use WebKit with Material-UI - YouTube
I'll break it down quickly and easily here as we style the horizontal and vertical scrollbar on a Material-UI Table.
Read more >
Bountysource
Scrollbars are rejected in MaterialUI Tables.
Read more >
material-table/Lobby - Gitter
@Domino987 Haha, I cannot reproduce it in a code sandbox. For some reason in the sandbox it's adding a horizontal scrollbar on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found