0

Is there a way to set initial scroll in reactjs material-ui tables?

The table I am using has many columns, and would prefer if some of the columns come into view automatically upon loading without scrolling i.e. setting initial scroll.

Is this even possible, and if yes, how?

2 Answers 2

1

You can check scrollLeft and scrollTop. You can change the property using javascript

Sign up to request clarification or add additional context in comments.

Comments

0

So, I found the solution best suited for myself.

I took three references:


  • one for the parent table
  • one for the first column of the table
  • one for the column till where I have to scroll

then within the useLayoutEffect, I use the getClientBoundingRect to get the coordinates of the two columns and finally use the tableRef.current.scrollTo() with the difference between the coordinates to scroll to the required position.

Comments

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.