Blazorise DataGrid: Virtualize
The DataGrid
Virtualize feature allows you to handle large data by limiting the data that's queried to what needs to be rendered in the UI.
Virtualization
By settingVirtualize
, you will enable virtualize capabilities on the DataGrid
, meaning that instead of having pagination, you’ll be able to scroll across the data with perceived improved performance.
Virtualization is a technique for limiting UI rendering to just the parts that are currently visible. For example, virtualization is helpful when the app must render a long list of items and only a subset of items is required to be visible at any given time.
You will still have access to every available DataGrid
feature. VirtualizeOptions
allows to further customize the Virtualize
feature.
Note that this mode requires that all rows have the same height.
Note that there is a known bug in .NET5 where Virtualize throws a
TaskCanceledException
on the background, this does not seem to crash your application.
TaskCanceledException when scrolling Virtualized component #28280<DataGrid TItem="Employee" Data="" @bind-SelectedRow="" Responsive RowStyling='(x,y ) => y.Style = "height: 70px;"' Virtualize VirtualizeOptions="@(new() { DataGridHeight = "250px"})"> <DataGridCommandColumn /> <DataGridColumn Field="@nameof(Employee.Id)" Caption="#" Sortable="false" /> <DataGridColumn Field="@nameof(Employee.FirstName)" Caption="First Name" Editable /> <DataGridColumn Field="@nameof(Employee.LastName)" Caption="Last Name" Editable /> <DataGridColumn Field="@nameof(Employee.Email)" Caption="Email" Editable /> <DataGridColumn Field="@nameof(Employee.Salary)" Caption="Salary" DisplayFormat="{0:C}" DisplayFormatProvider="@System.Globalization.CultureInfo.GetCultureInfo("fr-FR")" Editable> <EditTemplate> <NumericEdit TValue="decimal" Value="@((decimal)context.CellValue)" ValueChanged="@( v => context.CellValue = v)" /> </EditTemplate> </DataGridColumn> </DataGrid>
@code { [Inject] public EmployeeData EmployeeData { get; set; } private List<Employee> employeeList; private Employee selectedEmployee; protected override async Task OnInitializedAsync() { employeeList = await EmployeeData.GetDataAsync(); await base.OnInitializedAsync(); } }
API
See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.