Reputation: 699
I want to add vertical scroll if my data is too long. Horizontal scroll is working fine is data is too large but I am not getting how to vertical scroll in material table in react typescript ?
My code is -
{isLoading ?
(<Spinner></Spinner>)
: error && error.length > 0 ?
(<ErrorDetails error={error}></ErrorDetails>)
: result && (<div className={classes.root}>
{result && result.length > 0 ?
(<><MaterialTable
icons={icons}
columns={columns}
data={result}
options={{
exportButton: true,
sorting: true,
search: false,
paging: false,
fixedColumns: {
left: 2,
},
toolbar: false
}}
/> <section className={classes.rightToolbar}>
<Link className={classes.a} to="/scenarioDetails">
<OutlinedButtons></OutlinedButtons>
</Link>
</section></>)
: (<NoRecords></NoRecords>)}
</div>)}</>)
I have not added horizontal scroll but still it's working fine. But I wanna add vertical scroll so how can I get it done ?
Upvotes: 0
Views: 6535
Reputation: 924
you can use maxBodyHeight
property, which will create vertical scrollbar if data exceeding the given height.
<MaterialTable
options={{
maxBodyHeight: 400,
}}
/>
Upvotes: 2
Reputation: 1517
It's not up to MaterialTable props/settings. You might want to place the table within fixed height HTMLElement
Upvotes: 0