Very wide tables
With many rows, the grid draws only the visible rows (Data and rows). Columns work the same way. With 24 or more columns, horizontal scrolling draws only the cells of the visible columns. There is nothing to configure. Add columns and it applies.
In the demo, raise the column count up to 1000 and scroll sideways. The number below is how many cells were actually drawn in the first row. With 1000 columns, only what fits on screen exists.
When it turns on
- It turns on automatically when there are 24 or more unpinned columns. With fewer, every column is drawn and behavior is the same as before.
- There is no option to turn it on or off yet.
- Pinned columns (
pinned) are not virtualized and are always drawn, so many pinned columns means more DOM.
How it works
- It computes the visible range from the horizontal scroll position and draws two extra columns on each side, so fast scrolling does not show gaps.
- The header, body rows and group and total lines use the same range, so columns never drift out of line.
- When you scroll, only the cells of newly visible columns are refilled. The other cell nodes are reused as they are. If you use cell renderers, their cleanup runs when a node switches columns, and then the node is filled again.
- Header groups draw only the group cells that overlap the visible range.
What to know when combining features
- The DOM order of cells can differ from the column order. Screen readers follow each cell's
aria-colindex(its real position), and keyboard navigation does not depend on DOM order. In tests, find cells bydata-col-id, not bynth-child. - Cells of off-screen columns are not in the DOM. Code that reads values from DOM cells should read them from
getRows()and the column definitions instead. focusCell(rowKey, columnId)on a far column scrolls until that column is visible.- Moving, resizing and hiding columns work as usual (Resize, move and pin columns).
- If the header you are dragging scrolls out of the range during a column drag, its dimmed look disappears.
- Total column width beyond the browser's maximum element width is not supported. 1000 columns × 120 px (120,000 px) is fine.
Render, scroll and environment options
All defaults match 1.3.4. Turn on only what you need.
| Option | Value | Effect |
|---|---|---|
virtualize | { rows?: boolean; columns?: boolean } | A side set to false stops virtualizing and draws everything (both true by default); slow with many rows or columns |
scrollbars | { x?, y?: 'auto' | 'always' | 'hidden'; debounce? } | Always show or hide each axis. hidden still scrolls from code. debounce is 0-500 ms for the vertical scroll sync |
wheel | 'grid' (default) · 'passThrough' | 'passThrough' neither turns the wheel into horizontal scroll nor blocks it |
lockPageScrollWithPopup | boolean, default false | Lock the document scroll while a popup (menu, filter popup, picker, tooltip) is open |
tabIndex | integer, default 0 | The tabindex of the grid root; -1 is allowed |
keyPath | boolean, default true | false reads and writes a key such as a.b as that one property name only (edit and export included) |
domOrder | 'slot' (default) · 'screen' | 'screen' keeps row elements in screen order after scrolling |
virtualize.rows: falsedraws every row into the DOM. With thousands of rows the first draw and scrolling get visibly slower, so use it only when you must, for example for printing or capture.domOrder: 'screen'leaves rows that are already in place and moves only the ones that are out of order withinsertBefore. A row element that holds focus is never moved; the others are arranged around it, so focus and editing stay. The default'slot'reuses row elements, so after scrolling the DOM order can differ from the screen order (turn'screen'on if a screen reader follows the DOM order).wheel: the default'grid'turns the wheel into horizontal scroll when there is nothing to scroll vertically but the content overflows horizontally.'passThrough'skips that conversion, so the grid does not use the wheel and the page scrolls. With either value, wheel input past the end of the grid's scroll goes to the page.lockPageScrollWithPopupsetsoverflow: hiddenon the document scrolling element (and adds right padding of the scrollbar width so the layout does not jump) and restores the exact previous value when every popup is closed. Overlapping popups are counted.destroyreleases the lock.- With
scrollbars.debounceabove 0 the view is updated once after vertical scrolling stops. Fast scrolling may show blank areas meanwhile. keyPath: falseis for data with flat fields whose names contain dots. With the defaulttrue, a flat property of the same name is read first anyway.
Common pitfalls
I have 20 columns and every cell is drawn. Below 24 columns there is no virtualization. This is expected.
Adding pinned columns slowed horizontal scrolling. Pinned columns are always in the DOM. Pin only the ones you really need.
My columns have different widths. That is fine. When widths change, including by resizing, the range is recomputed.