Skip to content

Commit 2c7fbc6

Browse files
Troubleshooting of the Virtual Scrolling feature of the Grid KB article (#82)
* kb(grid): Troubleshooting of the Virtual Scrolling feature of the Grid * chore(grid): updated virtual row troubleshooting article * chore(kb): grid virtual scrolling kb optimizations Co-authored-by: Marin Bratanov <m.bratanov@gmail.com>
1 parent 83a5e37 commit 2c7fbc6

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: Virtual Scrolling Does Not Work
3+
description: How to fix Virtual Scrolling does not work and does not load data
4+
type: troubleshooting
5+
page_title: Virtual Scrolling - Not Working
6+
slug: grid-kb-virtual-scrolling-troubleshooting
7+
position:
8+
tags:
9+
res_type: kb
10+
---
11+
12+
## Environment
13+
<table>
14+
<tbody>
15+
<tr>
16+
<td>Product</td>
17+
<td>Grid for Blazor</td>
18+
</tr>
19+
</tbody>
20+
</table>
21+
22+
23+
## Description
24+
I have a Grid with [Virtual Scrolling]({%slug components/grid/virtual-scrolling%}) enabled. When I scroll up or down the rows for the current view port are not rendered as the loading indicator remains visible as shown in the image below.
25+
26+
>caption A depiction of the problem and symptom
27+
28+
![](images/virtual-scrolling-loading-indicator.png)
29+
30+
31+
## Cause\Possible Cause(s)
32+
33+
There are several common causes for that behavior:
34+
35+
* The rendered row height in the browser does not match the value set to the `RowHeight` parameter of the Grid. This depends on the used Theme and / or custom CSS rules applied to the `<tr>` HTML tag.
36+
37+
* The `RowHeight` parameter changes on runtime. Changing the height of the row dynamically depending on the content will cause issues with the virtualization logic.
38+
39+
* The browser and monitor settings do not match the settings of the Grid. Different browser zoom levels and monitor DPI (not set to 100%) can cause the browser to render the rows with unexpected dimensions and / or non-integer values of the `<tr>`.
40+
41+
>caption Typical PROBLEMATIC example when using Virtual Scrolling
42+
43+
````CSHTML
44+
@*This example showcases typical situation when the Virtual Scrolling will break*@
45+
46+
<TelerikGrid Data=@GridData
47+
ScrollMode="@GridScrollMode.Virtual"
48+
Height="480px"
49+
50+
RowHeight="20"
51+
52+
PageSize="20" Sortable="true" FilterMode="@GridFilterMode.FilterMenu">
53+
<GridColumns>
54+
<GridColumn Field="Id" />
55+
<GridColumn Field="Name" Title="First Name" />
56+
<GridColumn Field="LastName" Title="Last Name" />
57+
<GridColumn Field="HireData" Width="200px">
58+
<Template>
59+
@((context as SampleData).HireDate.ToString("MMMM dd, yyyy"))
60+
</Template>
61+
</GridColumn>
62+
</GridColumns>
63+
</TelerikGrid>
64+
65+
@code {
66+
public List<SampleData> GridData { get; set; }
67+
68+
protected override async Task OnInitializedAsync()
69+
{
70+
GridData = await GetData();
71+
}
72+
73+
private async Task<List<SampleData>> GetData()
74+
{
75+
return Enumerable.Range(1, 1000).Select(x => new SampleData
76+
{
77+
Id = x,
78+
Name = $"name {x}",
79+
LastName = $"Surname {x}",
80+
HireDate = DateTime.Now.Date.AddDays(-x)
81+
}).ToList();
82+
}
83+
84+
public class SampleData
85+
{
86+
public int Id { get; set; }
87+
public string Name { get; set; }
88+
public string LastName { get; set; }
89+
public DateTime HireDate { get; set; }
90+
}
91+
}
92+
````
93+
94+
95+
## Solution
96+
Set the `RowHeight` parameter to a fixed value in pixels so that it accommodates the content (depending on the content, padding, margins, font-size and other rules and settings on your app such the Theme and CSS related rules) and matches the monitor and browser settings.
97+
98+
You can read more in the [Notes section of the Virtual Scrolling article]({%slug components/grid/virtual-scrolling%}).
12 KB
Loading

0 commit comments

Comments
 (0)