Skip to content

Commit f3463e5

Browse files
ArgoZhangNullJutsu
andauthored
feat(SelectTable): add QueryAsync instance method (#5422)
* feat: add QueryAsync instance method * test: 更新单元测试 * chore: bump version 9.3.1-beta30 * chore: bump version Co-Authored-By: NullJutsu <[email protected]> --------- Co-authored-by: NullJutsu <[email protected]>
1 parent 4065f44 commit f3463e5

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.3.1-beta29</Version>
4+
<Version>9.3.1-beta31</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Select/SelectTable.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</CascadingValue>
4141
<RenderTemplate>
4242
<div class="dropdown-menu dropdown-table" style="@GetStyleString">
43-
<Table TableColumns="TableColumns" IsFixedHeader="true" IsBordered="true" IsStriped="true"
43+
<Table TableColumns="TableColumns" IsFixedHeader="true" IsBordered="true" IsStriped="true" @ref="_table"
4444
RenderMode="TableRenderMode.Table" ClickToSelect="true" AutoGenerateColumns="AutoGenerateColumns"
4545
ShowSearch="ShowSearch" SearchMode="SearchMode.Top"
4646
SearchModel="SearchModel" SearchTemplate="SearchTemplate" CollapsedTopSearch="CollapsedTopSearch"

src/BootstrapBlazor/Components/Select/SelectTable.razor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ namespace BootstrapBlazor.Components;
231231
.AddClass($"text-danger", IsValid.HasValue && !IsValid.Value)
232232
.Build();
233233

234+
private Table<TItem> _table = default!;
235+
234236
/// <summary>
235237
/// <inheritdoc/>
236238
/// </summary>
@@ -290,4 +292,10 @@ private async Task OnClearValue()
290292

291293
await OnClickRowCallback(default!);
292294
}
295+
296+
/// <summary>
297+
/// 查询方法
298+
/// </summary>
299+
/// <returns></returns>
300+
public Task QueryAsync() => _table.QueryAsync();
293301
}

test/UnitTest/Components/SelectTableTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ public void Items_Ok()
3636
});
3737
}
3838

39+
[Fact]
40+
public async Task QueryAsync_Ok()
41+
{
42+
var query = false;
43+
var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
44+
var items = Foo.GenerateFoo(localizer, 4);
45+
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
46+
{
47+
pb.AddChildContent<SelectTable<Foo>>(pb =>
48+
{
49+
pb.Add(a => a.AutoGenerateColumns, false);
50+
pb.Add(a => a.OnQueryAsync, options =>
51+
{
52+
query = true;
53+
return OnFilterQueryAsync(options, items);
54+
});
55+
pb.Add(a => a.GetTextCallback, foo => foo.Name);
56+
});
57+
});
58+
var table = cut.FindComponent<SelectTable<Foo>>();
59+
query = false;
60+
await cut.InvokeAsync(table.Instance.QueryAsync);
61+
Assert.True(query);
62+
}
63+
3964
[Fact]
4065
public async Task IsClearable_Ok()
4166
{

0 commit comments

Comments
 (0)