Skip to content

Commit 9fccdad

Browse files
authored
feat(Table): add ToolbarTemplate parameter (#5951)
* feat: 增加 ToolbarTemplate 参数 * test: 增加单元测试 * test: 更新单元测试 * chore: bump version 9.6.1-beta01
1 parent f57315d commit 9fccdad

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
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.6.1-beta02</Version>
4+
<Version>9.6.1-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Table/Table.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
@TableToolbarTemplate
7070
}
7171
</TableToolbar>
72+
@if (ToolbarTemplate != null)
73+
{
74+
<div class="float-start table-toolbar-template">
75+
@ToolbarTemplate
76+
</div>
77+
}
7278
<div class="float-end table-toolbar-button btn-group table-column-right">
7379
@if (TableExtensionToolbarBeforeTemplate != null)
7480
{

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ public partial class Table<TItem>
1515
[Parameter]
1616
public bool ShowToolbar { get; set; }
1717

18+
/// <summary>
19+
/// Gets or sets the template of table toolbar. Default is null.
20+
/// </summary>
21+
[Parameter]
22+
public RenderFragment? ToolbarTemplate { get; set; }
23+
1824
/// <summary>
1925
/// 获得/设置 首次加载是否显示加载骨架屏 默认 false 不显示 使用 <see cref="ShowLoadingInFirstRender" /> 参数值
2026
/// </summary>

src/BootstrapBlazor/Components/Table/Table.razor.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,15 @@ form .table .table-cell > textarea {
711711
}
712712
}
713713

714+
.table-toolbar-template {
715+
margin-block-end: .5rem;
716+
min-height: 35px;
717+
display: flex;
718+
flex-wrap: nowrap;
719+
align-items: center;
720+
justify-content: flex-start;
721+
}
722+
714723
@media (min-width: 576px) {
715724
.table-search .card-header .card-title {
716725
display: initial;

test/UnitTest/Components/TableTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,12 @@ public void ShowToolbar_Ok()
560560
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string)));
561561
builder.CloseComponent();
562562
});
563+
pb.Add(a => a.ToolbarTemplate, builder => builder.AddContent(0, "table-toolbar-template-content"));
563564
});
564565
});
565566
cut.Contains("float-end table-toolbar-button");
567+
cut.Contains("float-start table-toolbar-template");
568+
cut.Contains("table-toolbar-template-content");
566569
}
567570

568571
[Fact]

0 commit comments

Comments
 (0)