Skip to content
+

Data Grid - Scrolling

This section presents how to programmatically control the scroll.

Scrolling to specific cells

You can scroll to a specific cell by calling apiRef.current.scrollToIndexes(). The only argument that must be passed is an object containing the row index and the column index of the cell to scroll. If the row or column index is not present, the Data Grid will not do any movement in the missing axis.

The following demo explores the usage of this API:

Scroll restoration

You can restore scroll to a previous position by definining initialState.scroll values { top: number, left: number }. The Data Grid will mount at the specified scroll offset in pixels.

The following demo explores the usage of scroll restoration:

Press Enter to start editing

apiRef

The grid exposes a set of methods that enables all of these features using the imperative apiRef. To know more about how to use it, check the API Object section.

Signature:
getScrollPosition: () => GridScrollParams
Signature:
scroll: (params: Partial<GridScrollParams>) => void
Signature:
scrollToIndexes: (params: Partial<GridCellIndexCoordinates>) => boolean