Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Select/SelectTable.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</CascadingValue>
<RenderTemplate>
<div class="dropdown-menu dropdown-table" style="@GetStyleString">
<Table TableColumns="TableColumns" IsFixedHeader="true" IsBordered="true" IsStriped="true"
<Table TableColumns="TableColumns" IsFixedHeader="true" IsBordered="true" IsStriped="true" @ref="_table"
RenderMode="TableRenderMode.Table" ClickToSelect="true" AutoGenerateColumns="AutoGenerateColumns"
ShowSearch="ShowSearch" SearchMode="SearchMode.Top"
SearchModel="SearchModel" SearchTemplate="SearchTemplate" CollapsedTopSearch="CollapsedTopSearch"
Expand Down
8 changes: 8 additions & 0 deletions src/BootstrapBlazor/Components/Select/SelectTable.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ namespace BootstrapBlazor.Components;
.AddClass($"text-danger", IsValid.HasValue && !IsValid.Value)
.Build();

private Table<TItem> _table = default!;

/// <summary>
/// <inheritdoc/>
/// </summary>
Expand Down Expand Up @@ -290,4 +292,10 @@ private async Task OnClearValue()

await OnClickRowCallback(default!);
}

/// <summary>
/// 查询方法
/// </summary>
/// <returns></returns>
public Task QueryAsync() => _table.QueryAsync();
}
25 changes: 25 additions & 0 deletions test/UnitTest/Components/SelectTableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@ public void Items_Ok()
});
}

[Fact]
public async Task QueryAsync_Ok()
{
var query = false;
var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
var items = Foo.GenerateFoo(localizer, 4);
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
{
pb.AddChildContent<SelectTable<Foo>>(pb =>
{
pb.Add(a => a.AutoGenerateColumns, false);
pb.Add(a => a.OnQueryAsync, options =>
{
query = true;
return OnFilterQueryAsync(options, items);
});
pb.Add(a => a.GetTextCallback, foo => foo.Name);
});
});
var table = cut.FindComponent<SelectTable<Foo>>();
query = false;
await cut.InvokeAsync(table.Instance.QueryAsync);
Assert.True(query);
}

[Fact]
public async Task IsClearable_Ok()
{
Expand Down