TableVirtualizer
<ui5-table-virtualizer> | Since 2.5.0This 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
positionproperty 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
estimatedRowHeightbefore 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 theirpositiononly, never by their DOM identity. In frameworks like React, render the rows withkey={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
loadingproperty. 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-countfor theTableVirtualizer: This attribute specifies the total number of rows in the table. It helps the virtualizer determine the number of rows to manage. -
estimated-row-heightfor theTableVirtualizer(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. -
positionfor theTableRow: 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.
rowHeightsupplies an initial estimate, not a fixed height. ExplicitestimatedRowHeighttakes precedence, even when set to 44.extraRowsis multiplied by the configuredestimatedRowHeight, otherwiserowHeight, otherwise the legacy 45px default. Explicitoverscantakes 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 toundefinedrestores 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
extraRows
overscan
rowCount
rowHeight
Slots
No slots available for this component.
Events
range-change
Methods
reset
scrollToIndex
CSS Parts
No CSS parts available for this component.
CSS Custom States
No CSS custom states available for this component.