Bläddra i källkod

Add amendable OverscanCount parameter to the QuickGrid for virtualization. (#55078)

Matthew Leslie 1 år sedan
förälder
incheckning
aed195f2ad

+ 2 - 0
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/PublicAPI.Unshipped.txt

@@ -1 +1,3 @@
 #nullable enable
+Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.OverscanCount.get -> int
+Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.OverscanCount.set -> void

+ 1 - 0
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor

@@ -22,6 +22,7 @@
                     <Virtualize @ref="@_virtualizeComponent"
                         TItem="(int RowIndex, TGridItem Data)"
                         ItemSize="@ItemSize"
+                        OverscanCount="@OverscanCount"
                         ItemsProvider="@ProvideVirtualizedItems"
                         ItemContent="@(item => builder => RenderRow(builder, item.RowIndex, item.Data))"
                         Placeholder="@(placeholderContext => builder => RenderPlaceholderRow(builder, placeholderContext))" />

+ 8 - 0
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs

@@ -63,6 +63,14 @@ public partial class QuickGrid<TGridItem> : IAsyncDisposable
     /// </summary>
     [Parameter] public bool Virtualize { get; set; }
 
+    /// <summary>
+    /// This is applicable only when using <see cref="Virtualize"/>. It defines how many additional items will be rendered
+    /// before and after the visible region to reduce rendering frequency during scrolling. While higher values can improve
+    /// scroll smoothness by rendering more items off-screen, they can also increase initial load times. Finding a balance
+    /// based on your data set size and user experience requirements is recommended. The default value is 3.
+    /// </summary>
+    [Parameter] public int OverscanCount { get; set; } = 3;
+
     /// <summary>
     /// This is applicable only when using <see cref="Virtualize"/>. It defines an expected height in pixels for
     /// each row, allowing the virtualization mechanism to fetch the correct number of items to match the display