0

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 ?

2 Answers 2

2

you can use maxBodyHeight property, which will create vertical scrollbar if data exceeding the given height.

<MaterialTable
    options={{
      maxBodyHeight: 400,
    }}
/>
Sign up to request clarification or add additional context in comments.

1 Comment

That was a helpful answer to fix the height of table body. Is there a way to fix the location of table navigation bar (next, last, first, etc..). It means, having the scrollbar just over the navigation bar
0

It's not up to MaterialTable props/settings. You might want to place the table within fixed height HTMLElement

2 Comments

so how can I fix height in this case ?
It's based on your layout. The table will now take as much space as the data needs. In order to have a vertical scrollbar you would have to limit table's container height.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.