diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Pagination.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Pagination.cs index 61e323f2165476b8e2ac81ed53627eda857b9404..ccc475a95afe3d1550958300e67bb542522ba93e 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Pagination.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Pagination.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Components; using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; namespace BootstrapBlazor.Components @@ -39,7 +40,8 @@ namespace BootstrapBlazor.Components /// 获得/设置 每页显示数据数量的外部数据源 /// [Parameter] - public IEnumerable PageItemsSource { get; set; } = new int[] { 20, 50, 100, 200, 500, 1000 }; + [NotNull] + public IEnumerable? PageItemsSource { get; set; } /// /// 异步查询回调方法 diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.cs b/src/BootstrapBlazor/Components/Table/Table.razor.cs index c2f57049c542625721690bafcd2a1de4d3944357..3e3913d23efddbfade9c89db5d3ce9a42397c3a1 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.cs @@ -649,12 +649,6 @@ namespace BootstrapBlazor.Components Interop = new JSInterop>(JSRuntime); - // 初始化每页显示数量 - if (IsPagination) - { - PageItems = PageItemsSource.FirstOrDefault(); - } - // 设置 OnSort 回调方法 OnSortAsync = QueryAsync; @@ -717,6 +711,13 @@ namespace BootstrapBlazor.Components { base.OnParametersSet(); + // 初始化每页显示数量 + PageItemsSource ??= new int[] { 20, 50, 100, 200, 500, 1000 }; + if (IsPagination) + { + PageItems = PageItemsSource.FirstOrDefault(); + } + if (ScrollMode == ScrollMode.Virtual) { IsFixedHeader = true;