Skip to content

Commit 9efe35a

Browse files
984957: Updated the UG content and samples for Scrolling in DataGrid
1 parent 485e1ac commit 9efe35a

File tree

3 files changed

+12
-39
lines changed

3 files changed

+12
-39
lines changed

blazor/datagrid/infinite-scrolling.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ documentation: ug
1111

1212
The infinite scrolling feature in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid provides load-on-demand data retrieval to handle large datasets without degrading performance. In default infinite scrolling, the Grid fetches the next block of data when the vertical scrollbar reaches the end of the scroller, creating a seamless browsing experience across extensive data.
1313

14-
In this feature, a block is equivalent to the Grid’s [PageSize](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridPageSettings.html#Syncfusion_Blazor_Grids_GridPageSettings_PageSize). If `PageSize` is not set, the Grid calculates it from the viewport height and row height. To enable infinite scrolling, set [EnableInfiniteScrolling](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableInfiniteScrolling) to true and define a content [Height](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Height).
14+
In this feature, a block is equivalent to the Grid’s [PageSize](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridPageSettings.html#Syncfusion_Blazor_Grids_GridPageSettings_PageSize). If `PageSize` is not set, the Grid calculates it from the viewport height and row height. To enable infinite scrolling, set [EnableInfiniteScrolling](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableInfiniteScrolling) to **true** and define a content [Height](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Height).
1515

1616
> - With this feature, the Grid does not issue a new data request when revisiting a previously loaded page.
1717
> - The `Height` property must be specified when `EnableInfiniteScrolling` is enabled (a fixed container height is required).
1818
19-
The following is an example that demonstrates how to enable infinite scroll in the Grid:
20-
2119
{% tabs %}
2220
{% highlight razor tabtitle="Index.razor" %}
2321

@@ -88,8 +86,6 @@ At initial load, the Grid renders a specified number of data blocks (pages), whi
8886

8987
Configure this using [InitialBlocks](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridInfiniteScrollSettings.html) on [GridInfiniteScrollSettings](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridInfiniteScrollSettings.html). By default, three pages are rendered initially. Afterwards, additional data is buffered and loaded based on page size or the number of rows that fit within the given height.
9088

91-
The following example shows how to set the `initial blocks `based on a `DropDownList` selection:
92-
9389
{% tabs %}
9490
{% highlight razor tabtitle="Index.razor" %}
9591

@@ -189,11 +185,9 @@ public class TaskDetails
189185

190186
In Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid cache mode, previously loaded blocks are reused when revisited, reducing repeat data requests. The Grid manages the number of rendered DOM row elements using [GridInfiniteScrollSettings.MaximumBlocks](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridInfiniteScrollSettings.html#Syncfusion_Blazor_Grids_GridInfiniteScrollSettings_MaximumBlocks). When this limit is reached, the Grid removes an older block of row elements to render new ones.
191187

192-
Enable cache mode by setting [EnableCache](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridInfiniteScrollSettings.html#Syncfusion_Blazor_Grids_GridInfiniteScrollSettings_EnableCache) to true on [GridInfiniteScrollSettings](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridInfiniteScrollSettings.html).
193-
194-
Configure the maximum cached blocks with `MaximumBlocks` (default: 3).
188+
Enable cache mode by setting [EnableCache](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridInfiniteScrollSettings.html#Syncfusion_Blazor_Grids_GridInfiniteScrollSettings_EnableCache) to **true** on [GridInfiniteScrollSettings](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridInfiniteScrollSettings.html).
195189

196-
The following example toggles cache mode using a Switch component and updates the Grid accordingly:
190+
Configure the maximum cached blocks with `MaximumBlocks` (**default: 3**).
197191

198192
{% tabs %}
199193
{% highlight razor tabtitle="Index.razor" %}

blazor/datagrid/scrolling.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ documentation: ug
99

1010
# Scrolling in Blazor DataGrid
1111

12-
The scrolling feature in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid enables navigation through content that extends beyond the visible area of the Grid. Scrollbars appear automatically when content exceeds the specified `Width` or `Height` of the Grid element. This is useful for large datasets or when the Grid must fit within a constrained layout. The vertical and horizontal scrollbars are displayed based on the following criteria:
12+
The scrolling feature in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid enables navigation through content that extends beyond the visible area of the Grid. Scrollbars appear automatically when content exceeds the specified **Width** or **Height** of the Grid element. This is useful for large datasets or when the Grid must fit within a constrained layout. The vertical and horizontal scrollbars are displayed based on the following criteria:
1313

1414
* The vertical scrollbar appears when the total height of rows exceeds the Grid element’s height.
1515
* The horizontal scrollbar appears when the total width of columns exceeds the Grid element’s width.
1616
* The [Height](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Height) and [Width](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Width) properties define the Grid’s height and width.
1717

18-
> The default values for `Height` and `Width` are `auto`.
18+
> The default values for `Height` and `Width` are **auto**.
1919
2020
## Set width and height
2121

@@ -103,8 +103,6 @@ The Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid can fill it
103103

104104
To enable this, set the Grid’s [Width](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Width) and [Height](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Height) to 100%. The Grid’s parent element must have an explicit height; otherwise, a vertical scrollbar will not appear.
105105

106-
In the following example, the parent container has explicit height and width, and the Grid container is set to 100% for both dimensions to size responsively with its parent:
107-
108106
{% tabs %}
109107
{% highlight razor tabtitle="Index.razor" %}
110108

blazor/datagrid/virtual-scrolling.md

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@ documentation: ug
1111

1212
The virtual scrolling feature in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid efficiently handles large datasets by rendering only the rows currently visible in the viewport instead of the entire data source. This reduces DOM size, improves responsiveness, and lowers initial load time for datasets with thousands of records.
1313

14-
To learn about `virtualization` in the Grid, watch the following video:
15-
1614
{% youtube "youtube:https://www.youtube.com/watch?v=GrxmYYQPJPE"%}
1715

1816
## Row virtualization
1917

2018
Row virtualization is a technique that optimizes rendering performance for large datasets in data grids. Instead of loading all rows at once, it dynamically loads and renders only the rows visible within the viewport during vertical scrolling. This approach reduces the initial load time and memory usage, making it a more efficient alternative to traditional paging.
2119

22-
To configure row virtualization, set [EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization) to `true` and define a fixed content height using the [Height](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Height) property. The number of rendered records is implicitly determined by the content height. Optionally, you can influence the visible count using [GridPageSettings.PageSize](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridPageSettings.html#Syncfusion_Blazor_Grids_GridPageSettings_PageSize). Data is cached and reused while scrolling.
23-
24-
The following example enables row virtualization using the `EnableVirtualization` property.
20+
To configure row virtualization, set [EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization) to **true** and define a fixed content height using the [Height](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Height) property. The number of rendered records is implicitly determined by the content height. The visible count can be adjusted using [GridPageSettings.PageSize](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridPageSettings.html#Syncfusion_Blazor_Grids_GridPageSettings_PageSize) data is cached and reused while scrolling.
2521

2622
{% tabs %}
2723
{% highlight razor tabtitle="Index.razor" %}
@@ -91,8 +87,6 @@ public class TaskDetails
9187

9288
The [OverscanCount](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_OverscanCount) property in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid improves perceived scrolling performance by pre-rendering a buffer of rows before and after the visible viewport. This reduces the frequency of data fetches and DOM updates for smoother scrolling, and applies during both initial rendering and virtual scrolling.
9389

94-
The following example set `OverscanCount` to `5`, which preloaded five additional rows before and after the viewport.
95-
9690
{% tabs %}
9791
{% highlight razor tabtitle="Index.razor" %}
9892

@@ -184,11 +178,11 @@ public class OrderDetails
184178
2. Detail template
185179
3. Row template
186180
4. Autofill
187-
5. Hierarchy Grid
181+
188182
* With row virtual scrolling, copy-paste and drag-and-drop apply only to items within the current viewport.
189183
* Cell-based selection is not supported for row virtual scrolling.
190184
* Variable row heights in template columns—where each row has a different height—are not supported.
191-
* Group expand/collapse state is not persisted.
185+
* By default, the group expand/collapse state is not persisted. To persist the state, set the [GridGroupSettings.PersistGroupState](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridGroupSettings.html#Syncfusion_Blazor_Grids_GridGroupSettings_PersistGroupState) property to **true**. For more details, refer to the [documentation](https://blazor.syncfusion.com/documentation/datagrid/grouping#persist-grouped-row-expand-or-collapse-state).
192186
* Due to browser element height limits, the maximum number of records is bounded by browser capabilities.
193187
* Grid content height is calculated from row height and total record count; features that change row height (such as text wrapping) are not supported.
194188
* To increase row height while keeping all rows uniform, specify a fixed height:
@@ -207,9 +201,7 @@ public class OrderDetails
207201

208202
Column virtualization in Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid improves performance when many columns are present by rendering only the columns visible in the viewport. As the user scrolls horizontally, additional columns are loaded dynamically. This reduces initial render time and memory usage.
209203

210-
Enable it by setting [EnableColumnVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableColumnVirtualization) to `true`. For predictable behavior, assign explicit widths to columns (see [GridColumn.Width](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html#Syncfusion_Blazor_Grids_GridColumn_Width)).
211-
212-
The following example enables column virtualization using the `EnableColumnVirtualization` property.
204+
Enable it by setting [EnableColumnVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableColumnVirtualization) to **true**. For predictable behavior, assign explicit widths to columns (see [GridColumn.Width](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html#Syncfusion_Blazor_Grids_GridColumn_Width)).
213205

214206
{% tabs %}
215207
{% highlight razor tabtitle="Index.razor" %}
@@ -402,8 +394,6 @@ Column virtualization in Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor
402394

403395
Enabling both features together significantly improves the responsiveness and scalability of the Grid, even when working with thousands of rows and hundreds of columns.
404396

405-
The following example demonstrates both features enabled:
406-
407397
{% tabs %}
408398
{% highlight razor tabtitle="Index.razor" %}
409399

@@ -497,8 +487,6 @@ To configure this setup, set the following properties to true:
497487
* [EnableColumnVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableColumnVirtualization) – Enables rendering of only visible columns.
498488
* [AllowPaging](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_AllowPaging) – Enables paging to limit the number of rows per page.
499489

500-
The following example demonstrates enabling both column virtualization and paging:
501-
502490
{% tabs %}
503491
{% highlight razor tabtitle="Index.razor" %}
504492

@@ -587,9 +575,8 @@ public class OrderDetails
587575
### Limitations
588576

589577
* With column virtualization, column width must be in pixels; percentage values are not supported.
590-
* Selected column details are retained only within the current viewport; selection for off-screen columns is not preserved.
591578
* Cell selection is not supported with column virtualization.
592-
* Ctrl + Home and Ctrl + End keyboard shortcuts are not supported with column virtualization.
579+
* **Ctrl + Home** and **Ctrl + End** keyboard shortcuts are not supported with column virtualization.
593580
* The following features work within the viewport with column virtualization:
594581
1. Column resizing
595582
2. Column chooser
@@ -610,12 +597,10 @@ public class OrderDetails
610597

611598
The Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid offers an option to display cell placeholders while new data is being loaded during row or column virtualization. This feature improves user experience by showing a visual indicator (loading placeholder) in grid cells while data is being fetched. It is especially beneficial when working with large datasets or when virtualization is used to load data dynamically as scrolling occurs.
612599

613-
Set [EnableVirtualMaskRow](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualMaskRow) to `true` to reuse DOM elements and show placeholders until the incoming data is rendered.
600+
Set [EnableVirtualMaskRow](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualMaskRow) to **true** to reuse DOM elements and show placeholders until the incoming data is rendered.
614601

615602
This requires enabling either row virtualization ([EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization)) or column virtualization ([EnableColumnVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableColumnVirtualization)).
616603

617-
Heres an example demonstrating placeholders with both row and column virtualization enabled:
618-
619604
{% tabs %}
620605
{% highlight razor tabtitle="Index.razor" %}
621606

@@ -717,8 +702,6 @@ To enable frozen columns with virtualization:
717702

718703
**Enable Virtualization:** Turn on both [EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization) and [EnableColumnVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableColumnVirtualization).
719704

720-
Here's an example demonstrating frozen columns with row and column virtualization:
721-
722705
{% tabs %}
723706
{% highlight razor tabtitle="Index.razor" %}
724707

@@ -908,8 +891,6 @@ To ensure smooth scrolling behavior, virtualization must be enabled in the Grid.
908891
* **Horizontal scrolling:** enable both [EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization) and [EnableColumnVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableColumnVirtualization).
909892
* **Vertical scrolling:** enable [EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization).
910893

911-
The following example shows how to call `ScrollIntoViewAsync` from external buttons to navigate to a specific row or column.
912-
913894
{% tabs %}
914895
{% highlight razor tabtitle="Index.razor" %}
915896

@@ -1013,7 +994,7 @@ public class OrderDetails
1013994

1014995
The [UpdatePageSizeAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_UpdatePageSizeAsync_System_Int32_System_Int32_) method in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid refreshes the virtualized Grid’s PageSize externally by using the specified Grid height or container height along with the row height. This method calculates the `PageSize` programmatically and updates the Grid with the new value.
1015996

1016-
To enable external refresh of the virtualized Grid, set [EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization) to `true`.
997+
To enable external refresh of the virtualized Grid, set [EnableVirtualization](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableVirtualization) to **true**.
1017998

1018999
```cshtml
10191000
@using Syncfusion.Blazor.Grids

0 commit comments

Comments
 (0)