Virtual scrolling is an alternative to paging.
For runnable examples, refer to the demo on virtualization of remote data by the Grid.
Getting StartedWhen virtual scrolling is enabled, the Grid loads data from its remote data source while the user scrolls vertically.
@(Html.Kendo().Grid<AspNetCoreGrid.Models.OrderViewModel>()
.Name("grid")
.HtmlAttributes(new { style = "height: 380px;" })
.Scrollable(scrollable => scrollable.Virtual(true))
)
In virtual scrolling, the HTML output is different from the standard scrolling functionality—the data table of the Grid is not placed inside a scrollable container. The scrollbar belongs to a separate div.k-scrollbar
which affects scenarios when the data rows have to be manually scrolled to a particular position.
<div class="k-widget k-grid">
<div class="k-grid-header">
<div class="k-grid-header-wrap">
<table>...</table>
</div>
</div>
<div class="k-grid-content">
<div class="k-virtual-scrollable-wrap">
<table>...</table>
</div>
<div class="k-scrollbar k-scrollbar-vertical">
......
</div>
</div>
</div>
When the user scrolls a Grid in its virtual-scrolling mode, the Grid renders the table rows for the reached scroll position on the fly. If the Gris uses local data or if its remote data has already been loaded and cached, the rendering rate and performance of the widget depend on:
If the total number of items is large and the scrolling is fast, the table of the Grid can be re-rendered frequently. If, additionally, the page size is huge, the user might observe issues with the smoothness of the scrolling. In such cases, reduce the page size and increase the Grid height to improve the scrolling performance.
Virtual scrolling relies on a fake scrollbar. Its size is not determined by the browser but is calculated based on the average row height of the data that is already loaded. As a result, variable row heights may cause unexpected behavior such as an inability to scroll to the last rows on the last page. To ensure that all table rows have the same heights, use either of the following options:
.k-virtual-scrollable-wrap tr
{
height: 3em;
}
.k-virtual-scrollable-wrap td
{
white-space: nowrap;
}
Using on Mobile
On mobile devices where a scrollbar that can be grabbed and dragged is not visible, virtual scrolling of a large number of data items (for example thousands) might hinder the easy access to all table rows because the large number of data items will require a great deal of touch scrolling. On the other hand, using virtual scrolling with a very small number of items (for example, less than 200) does not make much sense. Virtual scrolling on touch devices relies on drag-and-drop events, which are slower than native scrolling. This might lead to performance issues.
Known LimitationsWhen virtual scrolling is not supported or recommended and depending on the number of data items, either revert to standard paging or to non-virtual scrolling without paging.
Activate()
event handler of the TabStrip.$('#GridID .k-scrollbar').scrollTop(0);
. In some scenarios, you might also need to call the refresh()
method.navigatable
, keyboard navigation supports only the Up Arrow
and Down Arrow
keys. The Page Up
and Page Down
key scrolling is not supported.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4