Skip to content

Commit ad49f3b

Browse files
docs(grid): improve virualized columns article
1 parent 820e698 commit ad49f3b

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

components/grid/columns/virtual.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,41 @@ title: Virtualized
33
page_title: Grid for Blazor | Virtual Columns
44
description: How to add virtual columns to a scrollable Grid.
55
slug: grid-columns-virtual
6-
tags: telerik,blazor,grid,column,virtual
6+
tags: telerik,blazor,grid,column,virtual,scrolling
77
published: true
88
position: 5
99
---
1010

1111
# Virtualized Columns
1212

13-
The Grid lets you add Virtualized Columns. This means that columns and the corresponding data will be rendered only for the currently visible viewport. When changing the [Page]({%slug components/grid/features/paging%}) or [Sorting]({%slug components/grid/features/sorting%}) the Grid less elements are rendered which improves the responsiveness and the overall user experience.
13+
The Telerik Blazor Grid provides Virtual Scrolling for its Columns. This means that columns and the corresponding data will be rendered only for the currently visible viewport. When changing the [Page]({%slug components/grid/features/paging%}) or [Sorting]({%slug components/grid/features/sorting%}) the Grid, fewer elements are rendered which improves the responsiveness and the overall user experience.
1414

15-
## Requirements
16-
To enable Virtualized Columns:
17-
* Set the `ColumnVirtualization` parameter of the Grid to `true`.
18-
* Set the `Width` parameter of the Grid in `px`.
19-
* Set the `Width` parameter of all columns in `px` so that the total sum is greater than the `Width` of the Grid which will enable horizontal scrollbar. You can read more about the scrolling behavior of the grid in the [Grid Column Width Behavior]({%slug grid-columns-width%}) article.
20-
* Set the `RowHeight` so that the content of all cells fit in the row. For more information see the [Notes](#notes) section.
21-
* Set the `Height` of the Grid in `px`. For more information see the [Notes](#notes) section.
22-
23-
24-
This article will be separated in the following sections:
15+
This article provides the following sections:
2516
* [Basics](#basics)
26-
* [Virtualized Columns and Rows](#virtualized-columns-and-rows)
27-
* [Virtualized Autogenerated Columns](#virtualized-autogenerated-columns)
2817
* [Notes](#notes)
18+
* [More Examples](#more-examples)
19+
* [Virtualized Columns and Rows](#virtualized-columns-and-rows)
20+
* [Virtualized Autogenerated Columns](#virtualized-autogenerated-columns)
2921

3022

3123
## Basics
3224

33-
The targeted scenario is for Grid with big volume of columns, since the performance improvement will be most significant there.
25+
The targeted scenario is for a Grid with big number of columns, since the performance improvement will be most significant there.
26+
27+
To enable Virtualized Columns:
28+
29+
1. Set the `ColumnVirtualization` parameter of the Grid to `true`.
30+
1. Set the `Width` parameter of all columns in `px` so that the total sum is greater than the `Width` of the Grid
31+
* This will enable horizontal scrollbar which is required. You can read more about the scrolling behavior of the grid in the [Grid Column Width Behavior]({%slug grid-columns-width%}) article.
32+
1. Set the `RowHeight` so that the content of all cells fits in the row. For more information see the [Notes](#notes) section.
33+
1. Set the `Height` of the Grid in `px`. For more information see the [Notes](#notes) section.
34+
35+
3436

3537
>caption Basic setup of the Virtualized Columns
3638
3739
````CSHTML
38-
@*Observe the behavior of the Grid with enabled ColumnVirtualization*@
40+
@* Observe the behavior of the Grid with enabled ColumnVirtualization *@
3941
4042
<TelerikGrid Data="@MyData"
4143
Width="800px"
@@ -87,7 +89,6 @@ The targeted scenario is for Grid with big volume of columns, since the performa
8789
get
8890
{
8991
string fullName = $"{FirstName} {LastName}";
90-
9192
return fullName;
9293
}
9394
}
@@ -98,7 +99,6 @@ The targeted scenario is for Grid with big volume of columns, since the performa
9899
{
99100
var timeSpan = DateTime.Today - DateOfBirth;
100101
var years = timeSpan.Days / 365;
101-
102102
return years;
103103
}
104104
}
@@ -110,9 +110,25 @@ The targeted scenario is for Grid with big volume of columns, since the performa
110110
}
111111
}
112112
````
113-
>caption The result from the code snippet above
113+
>caption The result from the code snippet above - scrolling through the grid is the same as without virtual scrolling, but the rendering performance and responsiveness of all other actions will be improved.
114114
![gif of virtual columns](images/virtual-columns-basic.gif)
115115

116+
117+
## Notes
118+
119+
* The `RowHeight` must accommodate the height of all the possible cells and their content in order to ensure good appearance. If certain cells that are not rendered have content that is taller than the rendered ones, you may experience glitches and unstable scrolling.
120+
* If the row/cell height the browser would render is larger than the `RowHeight` value due to the cell contents, the browser will ignore the `RowHeight`. The actual cell height can depend on the chosen Theme or other CSS rules, or on cell data that falls on more than one line. Inspect the rendered HTML to make sure the grid setting matches the rendering.
121+
* The `Height` of the Grid must be explicitly set in `px`. By default the Height is set by the browser depending on the contents. When a new column is rendered during horizontal scrolling, it might increase or decrease the vertical size of the row and cause issues with the rendering and abnormal visual behavior for the users.
122+
* Rendering the Virtual Columns in Client-side Blazor Applications is slower due to the Framework rendering limitations. In the Server-side Applications this issue is not present.
123+
124+
125+
## More Examples
126+
127+
The column virtualization can work together with other similar features in the grid:
128+
129+
* [With Row Virtualization](#virtualized-columns-and-rows)
130+
* [With Automatically Generated Columns](#virtualized-autogenerated-columns)
131+
116132
## Virtualized Columns and Rows
117133

118134
You can use Virtualized Columns and Rows together. More information on Virtual Rows can be found in the [Virtual Scrolling]({%slug components/grid/virtual-scrolling%}) article.
@@ -172,7 +188,6 @@ You can use Virtualized Columns and Rows together. More information on Virtual R
172188
get
173189
{
174190
string fullName = $"{FirstName} {LastName}";
175-
176191
return fullName;
177192
}
178193
}
@@ -183,7 +198,6 @@ You can use Virtualized Columns and Rows together. More information on Virtual R
183198
{
184199
var timeSpan = DateTime.Today - DateOfBirth;
185200
var years = timeSpan.Days / 365;
186-
187201
return years;
188202
}
189203
}
@@ -201,7 +215,9 @@ You can use Virtualized Columns and Rows together. More information on Virtual R
201215

202216
## Virtualized Autogenerated Columns
203217

204-
In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter must be set. For more information on Autogenerated columns you can read the [Automatically Generated Columns]({%slug grid-columns-automatically-generated%}) article.
218+
Column virtualization is commonly used when you have many columns. You may not have to declare them yourself, the grid can do this for your through its [Automatically Generated Columns]({%slug grid-columns-automatically-generated%}) feature.
219+
220+
>note In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter must be set in pixels.
205221
206222
````CSHTML
207223
@*Grid with Virtual Autogenerated Columns*@
@@ -252,7 +268,6 @@ In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter m
252268
get
253269
{
254270
string fullName = $"{FirstName} {LastName}";
255-
256271
return fullName;
257272
}
258273
}
@@ -267,7 +282,6 @@ In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter m
267282
{
268283
var timeSpan = DateTime.Today - DateOfBirth;
269284
var years = timeSpan.Days / 365;
270-
271285
return years;
272286
}
273287
}
@@ -293,10 +307,7 @@ In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter m
293307
294308
![gif of virtual columns](images/virtual-columns-autogenerated.gif)
295309

296-
## Notes
297-
* Rendering the Virtual Columns in Client-side Blazor Applications is slower due to the Framework rendering limitations. In the Server-side Applications this issue is not present.
298-
* The `RowHeight` must accommodate the height of all the possible cells and their content in order to ensure good appearance. If certain cells that are not rendered have content that is taller than the rendered ones, you may experience glitches and unstable scrolling. If the row/cell height the browser would render is larger than the `RowHeight` value, the browser will ignore it. It can depend on the chosen Theme or other CSS rules, or on cell data that falls on more than one row. Inspect the rendered HTML to make sure the grid setting matches the rendering.
299-
* The `Height` of the Grid must be explicitly set in `px`. By default the Height is calculated. When a new row is rendered during horizontal scrolling it might increase the horizonal size of the Grid and cause issues with the rendering and abnormal visual behavior for the users.
310+
300311

301312

302313
## See also

0 commit comments

Comments
 (0)