Skip to main content

TableVirtualizer

<ui5-table-virtualizer> | Since 2.5.0
info

This component is not intended to be used in a productive enviroment. The API is under development and may be changed in the future.

The ui5-table-virtualizer component is used inside a table with a defined height to virtualize its rows. Both Scroll and Popin overflow modes use the table's internal scroll container when virtualization is enabled. It is responsible for rendering only the rows that are visible in the viewport and updating them on scroll. This allows large numbers of rows to exist, but maintain high performance by only paying the cost for those that are currently visible.

Rendering Contract​

The virtualizer does not create or own any rows. Whenever the range of rows that should be rendered changes, the range-change event is fired, and the application renders the rows from first (inclusive) to last (exclusive):

  • The rows must be rendered in ascending order as a contiguous block, and the position property of every row must be set to its 0-based logical index.
  • Rows can have different heights. The heights are measured once the rows are rendered. Rows that have not yet been rendered are estimated with the average measured row height, or estimatedRowHeight before any row is measured.
  • Row elements may be reused freely (e.g. by rebinding an existing row to a new position, or by keeping a pool of detached rows). The virtualizer tracks the rows by their position only, never by their DOM identity. In frameworks like React, render the rows with key={position}, so that the framework reuses the row elements of the rows that stay in the range.
  • Rows whose data is not available yet can be rendered as placeholders by setting their loading property. Keep the cells of loading rows, their content can be empty. Loading rows have the estimated row height, and their height does not affect the row height estimation.

Note: Group headers (ui5-table-group-row) have their own position and count towards rowCount, just like data rows. The application renders the group headers; the virtualizer does not add offscreen or sticky group headers. Note: The measured heights are cached per row index. If rows are inserted, removed or reordered, call reset().

ES6 Module Import​

import "@ui5/webcomponents/dist/TableVirtualizer.js";

Basic Sample​

Enhance your table with virtualization capabilities by incorporating the Virtualizer feature.

Give the table a defined height. Both Scroll and Popin overflow modes use the same internal scroll viewport when a virtualizer is present. Pop-in columns can change row heights; the virtualizer measures the complete row after layout.

Group headers (ui5-table-group-row) can be included in the virtualized range. Give every group header its own position and include it in row-count, alongside data rows. Render both types in contiguous, ascending order. The application supplies the group headers; virtualization does not insert missing group context or make headers sticky.

Up/Down navigation focuses the group header itself and preserves the data-cell column when continuing to a data row, just like a non-virtualized table.

For effective table virtualization, the range-change event with its first (inclusive) and last (exclusive) parameters determines which rows need to be rendered. To ensure proper virtualization, you must set the following attributes:

  • row-count for the TableVirtualizer: This attribute specifies the total number of rows in the table. It helps the virtualizer determine the number of rows to manage.

  • estimated-row-height for the TableVirtualizer (optional): Rows can have different heights. The heights are measured when the rows are rendered, and rows that have not been rendered yet are estimated. A good estimate makes the scrollbar accurate from the start.

  • position for the TableRow: This attribute determines the position of each row within the table. Proper positioning ensures that rows are rendered in the correct location when the user scrolls. The rows must be rendered in ascending order. Row elements can be reused for other positions.

Rows whose data is still loading can be rendered as placeholders by setting the loading property of the TableRow. Keep the cells of loading rows (their content can be empty). The row has the estimated row height, and its height does not affect the estimation.

Migrating the experimental properties​

rowHeight (row-height) and extraRows (extra-rows) remain available as deprecated aliases for a short migration period and will be removed in an upcoming release. Instead use estimatedRowHeight and overscan.

  • rowHeight supplies an initial estimate, not a fixed height. Explicit estimatedRowHeight takes precedence, even when set to 44.
  • extraRows is multiplied by the configured estimatedRowHeight, otherwise rowHeight, otherwise the legacy 45px default. Explicit overscan takes precedence, including 0 or 400. The converted buffer uses the new directional behavior, not the old symmetric row count.
  • With neither old nor new input supplied, the effective defaults remain a 44px initial estimate and 400px overscan. Unset input properties are undefined; removing an attribute or setting its property to undefined restores the fallback behavior.

For example, row-height="50" extra-rows="4" maps to an initial 50px estimate and 200px overscan. Migrate it to estimated-row-height="50" overscan="200". extra-rows="4" alone uses 180px overscan.

By setting these attributes and handling the range-change event properly, the TableVirtualizer can efficiently manage and render only the rows that are visible when the user scrolls.

Properties​

estimatedRowHeight​

DescriptionDefines the estimated height of the rows in pixels.
The estimate is used for rows that have not yet been rendered, until the first rows are measured. Afterwards, the average height of the measured rows is used. The closer the estimate is to the actual row heights, the more accurate the scrollbar is initially. When omitted, rowHeight is used if supplied; otherwise the initial estimate is 44 pixels.
Typenumber | undefined
Defaultundefined
Since2.30.0

extraRows​

DescriptionDefines a legacy rendering buffer in rows, converted to pixel-based, directional overscan. The multiplier is the configured estimatedRowHeight, otherwise rowHeight, otherwise 45 pixels. An explicitly supplied overscan takes precedence, including zero.
Typenumber | undefined
Defaultundefined
DeprecatedInstead use overscan in pixels. This experimental alias will be removed in an upcoming release.

overscan​

DescriptionDefines the extent in pixels that is rendered in addition to the visible area.
The full extent is rendered in the scrolling direction, half of it in the opposite direction. A larger value reduces the risk of blank areas during fast scrolling, a smaller value reduces the rendering costs. When omitted, extraRows is converted to pixels if supplied; otherwise 400 pixels are used.
Typenumber | undefined
Defaultundefined
Since2.30.0

rowCount​

DescriptionDefines the total count of rows in the table.
Note: For virtualization to work properly, this property is mandatory.
Typenumber
Default100

rowHeight​

DescriptionDefines a legacy initial row-height hint in pixels. It no longer enforces a fixed row height. An explicitly supplied estimatedRowHeight takes precedence.
Typenumber | undefined
Defaultundefined
DeprecatedInstead use estimatedRowHeight. This experimental alias will be removed in an upcoming release.

Slots​

No slots available for this component.

Events​

range-change​

DescriptionFired when the range of rows that should be rendered changes, e.g. on scrolling, on resizing, or on keyboard navigation.
The rows from first (inclusive) to last (exclusive) must be rendered in ascending order with their position property set.
TypeCustomEvent<RangeChangeEventDetail>
Parametersfirst: number
The 0-based index of the first row that should be rendered
last: number
The 0-based index after the last row that should be rendered (exclusive)
BubblesNo
CancelableNo

Methods​

reset​

DescriptionResets the virtualizer to its initial state, discards all measured row heights, scrolls to the top, and fires the range-change event.
Call this method if the rows are inserted, removed or reordered.
Return typevoid

scrollToIndex​

DescriptionScrolls the row with the given index into the viewport.
The row is kept aligned while the rows around it are rendered and measured, until the user scrolls.
Return typevoid
Parametersalignment: TableVirtualizerScrollAlignment
The alignment of the row within the viewport
index: number
The 0-based index of the row
Since2.30.0

CSS Parts​

No CSS parts available for this component.

CSS Custom States​

No CSS custom states available for this component.