Skip to content

Commit e8be200

Browse files
authored
refactor(Table): throw exception when set IsTree to true in virtualize mode (#5723)
* refactor: 增加约束 * test: 更新单元测试
1 parent f99ad91 commit e8be200

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/BootstrapBlazor/Components/Table/Table.razor.cs

+5
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,11 @@ protected override void OnParametersSet()
909909
{
910910
base.OnParametersSet();
911911

912+
if (ScrollMode == ScrollMode.Virtual && IsTree)
913+
{
914+
throw new InvalidOperationException($"{GetType()} does not support virtual scrolling in tree mode. ${GetType()} 目前不支持虚拟滚动模式下设置 IsTree=\"true\"");
915+
}
916+
912917
OnInitParameters();
913918

914919
if (Items != null && OnQueryAsync != null)

test/UnitTest/Components/TableTest.cs

+8
Original file line numberDiff line numberDiff line change
@@ -2693,6 +2693,7 @@ public void ScrollMode_Ok()
26932693
var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
26942694
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
26952695
{
2696+
pb.Add(a => a.EnableErrorLogger, false);
26962697
pb.AddChildContent<Table<Foo>>(pb =>
26972698
{
26982699
pb.Add(a => a.RenderMode, TableRenderMode.Table);
@@ -2710,6 +2711,13 @@ public void ScrollMode_Ok()
27102711
});
27112712
var virtualComponent = cut.FindComponent<Virtualize<Foo>>();
27122713
Assert.NotNull(virtualComponent);
2714+
2715+
var table = cut.FindComponent<Table<Foo>>();
2716+
var exception = Assert.Throws<InvalidOperationException>(() => table.SetParametersAndRender(pb =>
2717+
{
2718+
pb.Add(a => a.IsTree, true);
2719+
}));
2720+
Assert.NotNull(exception);
27132721
}
27142722

27152723
[Fact]

0 commit comments

Comments
 (0)