Skip to content

Is it possible to access the row virtualizer instance? #45

Answered by KevinVandy
mihaio100 asked this question in Q&A
Discussion options

You must be logged in to vote

Edit: There is now a virutalizerInstanceRef prop. It can be seen used in the infinite scrolling example

So there is currently no reference to the virtualizer currently, though I could probably expose a ref to it.

If all you are wanting to do is scroll to the top, you could do that with the muiTableContainerProps ref.

Something like this

  const tableContainerRef = useRef(null);

  //scroll to top of table when sorting or filters change
  useEffect(() => {
    if (tableContainerRef.current) {
      tableContainerRef.current.scrollTop = 0;
    }
  }, [sorting, columnFilters, globalFilter]);

...
<MaterialReactTable
  muiTableContainerProps={{
    ref: tableContainerRef
  }}
/>

But adding a …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mihaio100
Comment options

@KevinVandy
Comment options

@LukeParsnips
Comment options

Answer selected by mihaio100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants