diff --git a/src/BootstrapBlazor/Components/Table/Table.razor b/src/BootstrapBlazor/Components/Table/Table.razor index e0a925d96f7..e083fb21aac 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor +++ b/src/BootstrapBlazor/Components/Table/Table.razor @@ -369,13 +369,12 @@ { @if (Items != null) { - + } else { - diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs index fa8b766812e..7b60864524d 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs @@ -404,9 +404,9 @@ protected void OnClickCardView() private async Task QueryAsync(bool shouldRender, int? pageIndex = null, bool triggerByPagination = false) { - if (ScrollMode == ScrollMode.Virtual && VirtualizeElement != null) + if (ScrollMode == ScrollMode.Virtual && _virtualizeElement != null) { - await VirtualizeElement.RefreshDataAsync(); + await _virtualizeElement.RefreshDataAsync(); } else { diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.cs b/src/BootstrapBlazor/Components/Table/Table.razor.cs index 36187ef085d..d4138c9dd37 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.cs @@ -38,7 +38,8 @@ public partial class Table : ITable, IModelEqualityComparer where /// /// 获得/设置 内置虚拟化组件实例 /// - protected Virtualize? VirtualizeElement { get; set; } + [NotNull] + private Virtualize? _virtualizeElement = null; /// /// 获得 Table 组件样式表 diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs index 54527fb6684..29c77576725 100644 --- a/test/UnitTest/Components/TableTest.cs +++ b/test/UnitTest/Components/TableTest.cs @@ -8911,9 +8911,10 @@ public async Task TestLoopQueryAsync() public RenderFragment RenderVirtualPlaceHolder() => new(builder => { - if (ScrollMode == ScrollMode.Virtual && VirtualizeElement != null) + var fieldInfo = GetType().BaseType!.GetField("_virtualizeElement", BindingFlags.NonPublic | BindingFlags.Instance)!; + if (ScrollMode == ScrollMode.Virtual && fieldInfo.GetValue(this) is Virtualize element) { - builder.AddContent(0, VirtualizeElement.Placeholder?.Invoke(new Microsoft.AspNetCore.Components.Web.Virtualization.PlaceholderContext())); + builder.AddContent(0, element.Placeholder?.Invoke(new PlaceholderContext())); } });