You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
14
14
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:
25
16
*[Basics](#basics)
26
-
*[Virtualized Columns and Rows](#virtualized-columns-and-rows)
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
+
34
36
35
37
>caption Basic setup of the Virtualized Columns
36
38
37
39
````CSHTML
38
-
@*Observe the behavior of the Grid with enabled ColumnVirtualization*@
40
+
@*Observe the behavior of the Grid with enabled ColumnVirtualization*@
39
41
40
42
<TelerikGrid Data="@MyData"
41
43
Width="800px"
@@ -87,7 +89,6 @@ The targeted scenario is for Grid with big volume of columns, since the performa
87
89
get
88
90
{
89
91
string fullName = $"{FirstName} {LastName}";
90
-
91
92
return fullName;
92
93
}
93
94
}
@@ -98,7 +99,6 @@ The targeted scenario is for Grid with big volume of columns, since the performa
98
99
{
99
100
var timeSpan = DateTime.Today - DateOfBirth;
100
101
var years = timeSpan.Days / 365;
101
-
102
102
return years;
103
103
}
104
104
}
@@ -110,9 +110,25 @@ The targeted scenario is for Grid with big volume of columns, since the performa
110
110
}
111
111
}
112
112
````
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.
114
114

115
115
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:
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
172
188
get
173
189
{
174
190
string fullName = $"{FirstName} {LastName}";
175
-
176
191
return fullName;
177
192
}
178
193
}
@@ -183,7 +198,6 @@ You can use Virtualized Columns and Rows together. More information on Virtual R
183
198
{
184
199
var timeSpan = DateTime.Today - DateOfBirth;
185
200
var years = timeSpan.Days / 365;
186
-
187
201
return years;
188
202
}
189
203
}
@@ -201,7 +215,9 @@ You can use Virtualized Columns and Rows together. More information on Virtual R
201
215
202
216
## Virtualized Autogenerated Columns
203
217
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.
205
221
206
222
````CSHTML
207
223
@*Grid with Virtual Autogenerated Columns*@
@@ -252,7 +268,6 @@ In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter m
252
268
get
253
269
{
254
270
string fullName = $"{FirstName} {LastName}";
255
-
256
271
return fullName;
257
272
}
258
273
}
@@ -267,7 +282,6 @@ In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter m
267
282
{
268
283
var timeSpan = DateTime.Today - DateOfBirth;
269
284
var years = timeSpan.Days / 365;
270
-
271
285
return years;
272
286
}
273
287
}
@@ -293,10 +307,7 @@ In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter m
293
307
294
308

295
309
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.
0 commit comments