Skip to content

Commit 8c329b9

Browse files
authored
doc(Table): update ShowMoreButton documentation (#7427)
* doc: 移动 ShowMoreButton 示例 * doc: 更新 ShowMoreButton 示例 * doc: 更新更多按钮模板文档
1 parent 9481475 commit 8c329b9

6 files changed

Lines changed: 46 additions & 18 deletions

File tree

src/BootstrapBlazor.Server/Components/Samples/Table/TablesColumn.razor

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@page "/table/column"
1+
@page "/table/column"
22
@inject IStringLocalizer<NavMenu> NavMenuLocalizer
33
@inject IStringLocalizer<TablesColumn> Localizer
44
@inject IStringLocalizer<Foo> FooLocalizer
@@ -218,6 +218,34 @@
218218
</Table>
219219
</DemoBlock>
220220

221+
<DemoBlock Title="@Localizer["ShowMoreButtonTitle"]" Introduction="@Localizer["ShowMoreButtonIntro"]" Name="ShowMoreButton">
222+
<section ignore>
223+
<p>@((MarkupString)Localizer["ShowMoreButtonDesc"].Value)</p>
224+
<Pre>&lt;MoreButtonDropdownTemplate&gt;
225+
&lt;DropdownItem Text="Action1" Icon="fa-solid fa-flag" OnClick="@@(() =&gt; OnAction(context, "Action1"))"&gt;&lt;/DropdownItem&gt;
226+
&lt;Divider&gt;&lt;/Divider&gt;
227+
&lt;DropdownItem Text="Action2" Icon="fa-solid fa-home" OnClick="@@(() =&gt; OnAction(context, "Action2"))"&gt;&lt;/DropdownItem&gt;
228+
&lt;/MoreButtonDropdownTemplate&gt;</Pre>
229+
</section>
230+
<Table TItem="Foo"
231+
IsPagination="true" PageItemsSource="new int[] {10, 20}"
232+
IsStriped="true" IsBordered="true" ShowMoreButton="true"
233+
ShowToolbar="true" ShowCardView="true" IsMultipleSelect="true" ShowExtendButtons="true"
234+
ShowEmpty="true" OnQueryAsync="@OnQueryAsync">
235+
<TableColumns>
236+
<TableColumn @bind-Field="@context.DateTime" Width="180" />
237+
<TableColumn @bind-Field="@context.Name" />
238+
<TableColumn @bind-Field="@context.Address" />
239+
<TableColumn @bind-Field="@context.Education" />
240+
</TableColumns>
241+
<MoreButtonDropdownTemplate>
242+
<DropdownItem Text="Action1" Icon="fa-solid fa-flag" OnClick="@(() => OnAction(context, "Action1"))"></DropdownItem>
243+
<Divider></Divider>
244+
<DropdownItem Text="Action2" Icon="fa-solid fa-home" OnClick="@(() => OnAction(context, "Action2"))"></DropdownItem>
245+
</MoreButtonDropdownTemplate>
246+
</Table>
247+
</DemoBlock>
248+
221249
<DemoBlock Title="@Localizer["AdvanceTitle"]" Introduction="@Localizer["AdvanceIntro"]" Name="Advance">
222250
<Table TItem="Foo" IsPagination="true" PageItemsSource="@PageItemsSource" RenderMode="TableRenderMode.Table"
223251
IsStriped="true" IsBordered="true" OnQueryAsync="OnQueryAsync">

src/BootstrapBlazor.Server/Components/Samples/Table/TablesColumn.razor.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -192,6 +192,11 @@ private class Company(string name)
192192
public string Name { get; set; } = name;
193193
}
194194

195+
[Inject, NotNull]
196+
private ToastService? ToastService { get; set; }
197+
198+
private Task OnAction(Foo foo, string actionName) => ToastService.Information(foo.Name, $"Trigger {actionName}");
199+
195200
/// <summary>
196201
/// 示例复杂类型 ComplexFoo
197202
/// Complex class sample ComplexFoo
@@ -239,8 +244,7 @@ public ComplexFoo(int age)
239244
/// 返回一个含有随机数据的 ComplexFoo 实例集合
240245
/// Return a List of ComplexFoo instances with random data
241246
/// </returns>
242-
public static List<ComplexFoo> GenerateComplexFoo(IStringLocalizer<Foo> localizer, int count = 80)
243-
=> Enumerable.Range(1, count).Select(i => new ComplexFoo(Random.Shared.Next(20, 65))
247+
public static List<ComplexFoo> GenerateComplexFoo(IStringLocalizer<Foo> localizer, int count = 80) => Enumerable.Range(1, count).Select(i => new ComplexFoo(Random.Shared.Next(20, 65))
244248
{
245249
Id = i,
246250
Name = localizer["Foo.Name", $"{i:d4}"],

src/BootstrapBlazor.Server/Components/Samples/Table/TablesSearch.razor

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@page "/table/search"
1+
@page "/table/search"
22
@inject IStringLocalizer<NavMenu> NavMenuLocalizer
33
@inject IStringLocalizer<TablesSearch> Localizer
44
@inject IStringLocalizer<Foo> FooLocalizer
@@ -49,11 +49,6 @@
4949
</div>
5050
</GroupBox>
5151
</SearchTemplate>
52-
<MoreButtonDropdownTemplate>
53-
<DropdownItem Text="Action1" Icon="fa-solid fa-flag" OnClick="@(() => OnAction(context, "Action1"))"></DropdownItem>
54-
<Divider></Divider>
55-
<DropdownItem Text="Action2" Icon="fa-solid fa-home" OnClick="@(() => OnAction(context, "Action2"))"></DropdownItem>
56-
</MoreButtonDropdownTemplate>
5752
</Table>
5853
</div>
5954
</DemoBlock>

src/BootstrapBlazor.Server/Components/Samples/Table/TablesSearch.razor.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -183,9 +183,4 @@ private Task<QueryData<Foo>> OnQueryAsync(QueryPageOptions options)
183183
IsAdvanceSearch = options.CustomerSearches.Count > 0 && string.IsNullOrEmpty(options.SearchText),
184184
});
185185
}
186-
187-
[Inject, NotNull]
188-
private ToastService? ToastService { get; set; }
189-
190-
private Task OnAction(Foo foo, string actionName) => ToastService.Information(foo.Name, $"Trigger {actionName}");
191186
}

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5108,7 +5108,10 @@
51085108
"ColumnIgnoreIntro": "By setting the <code>Ignore</code> parameter to control whether the column is rendered, this parameter is different from <code>Visible</code>. Setting<code>Visible=\"false\"</code> to not display the column can be checked and displayed in the list through <code>ShowColumnList=\"true\"</code>",
51095109
"ColumnIgnoreButtonText": "Ignoring/Not Ignoring",
51105110
"ColumnOrderTitle": "Column Order",
5111-
"ColumnOrderIntro": "Set the order by setting the <code>Order</code> parameter of <code>TableColumn</code>"
5111+
"ColumnOrderIntro": "Set the order by setting the <code>Order</code> parameter of <code>TableColumn</code>",
5112+
"ShowMoreButtonTitle": "ShowMoreButton",
5113+
"ShowMoreButtonIntro": "By setting the <code>ShowMoreButton</code> parameter, a <b>More</b> button appears when the row expands. Furthermore, by setting the <code>MoreButtonDropdownTemplate</code> template, the dropdown menu options are customized. This design significantly reduces the amount of row space occupied.",
5114+
"ShowMoreButtonDesc": "<code>MoreButtonDropdownTemplate</code> Context <code>context</code> is the instance of the current row."
51125115
},
51135116
"BootstrapBlazor.Server.Components.Samples.Table.TablesColumnDrag": {
51145117
"TablesColumnTitle": "Table Column",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5108,7 +5108,10 @@
51085108
"ColumnIgnoreIntro": "通过设置 <code>Ignore</code> 参数控制列是否渲染,此参数与 <code>Visible</code> 不同,设置 <code>Visible=\"false\"</code> 后不显示列可通过 <code>ShowColumnList=\"true\"</code> 在列表中勾选并显示",
51095109
"ColumnIgnoreButtonText": "忽略/不忽略",
51105110
"ColumnOrderTitle": "列顺序",
5111-
"ColumnOrderIntro": "通过设置 <code>TableColumn</code> 的 <code>Order</code> 参数进行设置顺序"
5111+
"ColumnOrderIntro": "通过设置 <code>TableColumn</code> 的 <code>Order</code> 参数进行设置顺序",
5112+
"ShowMoreButtonTitle": "更多按钮",
5113+
"ShowMoreButtonIntro": "通过设置 <code>ShowMoreButton</code> 参数使行扩展按钮出现 <b>更多</b> 按钮,通过设置 <code>MoreButtonDropdownTemplate</code> 模板自定义下拉菜单选项,通过这样的设计大大减少行空间占用",
5114+
"ShowMoreButtonDesc": "<code>MoreButtonDropdownTemplate</code> 上下文 <code>context</code> 为当前行实例"
51125115
},
51135116
"BootstrapBlazor.Server.Components.Samples.Table.TablesColumnDrag": {
51145117
"TablesColumnTitle": "Table 表格",

0 commit comments

Comments
 (0)