Skip to content

Commit 1825080

Browse files
Lambert LeeArgoZhang
authored andcommitted
!3777 doc(#I6B4SA): update TableSelection demo
* update TablesSelectionNormal demo
1 parent 269580f commit 1825080

5 files changed

Lines changed: 102 additions & 99 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
@inject IStringLocalizer<TablesSelectionNormal> Localizer
2+
@inject IStringLocalizer<Foo> LocalizerFoo
3+
4+
<div>
5+
<Table TItem="Foo" @bind-SelectedRows="SelectedItems"
6+
IsPagination="true" PageItemsSource="@PageItemsSource"
7+
IsStriped="true" IsBordered="true" IsMultipleSelect="true"
8+
ShowToolbar="true" ShowDefaultButtons="false" OnQueryAsync="@OnQueryAsync">
9+
<TableColumns>
10+
<TableColumn @bind-Field="@context.DateTime" Width="180" />
11+
<TableColumn @bind-Field="@context.Name" Width="100" />
12+
<TableColumn @bind-Field="@context.Address" />
13+
<TableColumn @bind-Field="@context.Count" />
14+
</TableColumns>
15+
</Table>
16+
17+
<Tips class="mt-3">
18+
<div>@((MarkupString)Localizer["TablesSelectionNormalTips"].Value)</div>
19+
</Tips>
20+
21+
<p class="mt-3">@Localizer["TablesSelectionNormalSelectRow"]:</p>
22+
<ul class="ul-demo mb-3">
23+
@foreach (var item in SelectedItems)
24+
{
25+
<li>@item.Name</li>
26+
}
27+
</ul>
28+
29+
<Button OnClick="OnClick" Color="Color.Primary">@Localizer["TablesSelectionNormalButtonText"]</Button>
30+
31+
</div>
32+
33+
@code {
34+
/// <summary>
35+
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
36+
/// Foo class is used for Demo test, please download the source code if necessary
37+
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
38+
/// </summary>
39+
[NotNull]
40+
private List<Foo>? Items { get; set; }
41+
42+
[NotNull]
43+
private List<Foo>? SelectedItems { get; set; }
44+
45+
private static IEnumerable<int> PageItemsSource => new int[] { 4, 10, 20 };
46+
47+
/// <summary>
48+
/// OnInitialized
49+
/// </summary>
50+
protected override void OnInitialized()
51+
{
52+
base.OnInitialized();
53+
54+
Items = Foo.GenerateFoo(LocalizerFoo);
55+
SelectedItems = Items.Take(4).ToList();
56+
}
57+
58+
private void OnClick()
59+
{
60+
SelectedItems.Clear();
61+
}
62+
63+
private Task<QueryData<Foo>> OnQueryAsync(QueryPageOptions options)
64+
{
65+
var total = Items.Count;
66+
var items = Items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems).ToList();
67+
68+
return Task.FromResult(new QueryData<Foo>()
69+
{
70+
Items = items,
71+
TotalCount = total,
72+
IsSorted = true,
73+
IsFiltered = true,
74+
IsSearch = true
75+
});
76+
}
77+
}

src/BootstrapBlazor.Shared/Locales/en.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5434,13 +5434,15 @@
54345434
"TablesAutoRefreshControlIsAutoRefresh": "The current value"
54355435
},
54365436
"BootstrapBlazor.Shared.Samples.Table.TablesSelection": {
5437-
"H1": "Table Selection",
5438-
"H2": "Set the table row state by setting <code>SelectedRows</code>, and set the highlight by selecting the style",
5439-
"P1": "Set row selection function",
5440-
"P2": "Defaults to the selected state when the table is initialized by setting the <code>SelectedRows</code> property collection",
5441-
"P3": "Maintain line state fallback mechanism, <code>ModelEqualityComparer</code> <code>CustomKeyAttribute</code> <code>IEqualityComparer&lt;TItem&gt;</code> <code>Equals</code> overloaded method",
5442-
"P4": "selected row record",
5443-
"P5": "clear selection"
5437+
"TablesSelectionTitle": "Table Selection",
5438+
"TablesSelectionDescription": "Set the table row state by setting <code>SelectedRows</code>, and set the highlight by selecting the style",
5439+
"TablesSelectionNormalTitle": "Set row selection function",
5440+
"TablesSelectionNormalIntro": "Defaults to the selected state when the table is initialized by setting the <code>SelectedRows</code> property collection"
5441+
},
5442+
"BootstrapBlazor.Shared.Demos.Table.TablesSelection.TablesSelectionNormal": {
5443+
"TablesSelectionNormalTips": "Maintain line state fallback mechanism, <code>ModelEqualityComparer</code> <code>CustomKeyAttribute</code> <code>IEqualityComparer&lt;TItem&gt;</code> <code>Equals</code> overloaded method",
5444+
"TablesSelectionNormalSelectRow": "selected row record",
5445+
"TablesSelectionNormalButtonText": "clear selection"
54445446
},
54455447
"BootstrapBlazor.Shared.Samples.Table.TablesExcel": {
54465448
"H1": "Table Excel",

src/BootstrapBlazor.Shared/Locales/zh.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5449,13 +5449,15 @@
54495449
"TablesAutoRefreshControlIsAutoRefresh": "当前值"
54505450
},
54515451
"BootstrapBlazor.Shared.Samples.Table.TablesSelection": {
5452-
"H1": "Table 表格",
5453-
"H2": "通过设置 <code>SelectedRows</code> 设置表格行状态,通过选中样式可以设置高亮",
5454-
"P1": "设置选中行功能",
5455-
"P2": "通过设置 <code>SelectedRows</code> 属性集合初始化表格时默认为选中状态",
5456-
"P3": "保持行状态回落机制,<code>ModelEqualityComparer</code> <code>CustomKeyAttribute</code> <code>IEqualityComparer&lt;TItem&gt;</code> <code>Equals</code> 重载方法",
5457-
"P4": "选中的行记录",
5458-
"P5": "清除选择"
5452+
"TablesSelectionTitle": "Table 表格",
5453+
"TablesSelectionDescription": "通过设置 <code>SelectedRows</code> 设置表格行状态,通过选中样式可以设置高亮",
5454+
"TablesSelectionNormalTitle": "设置选中行功能",
5455+
"TablesSelectionNormalIntro": "通过设置 <code>SelectedRows</code> 属性集合初始化表格时默认为选中状态"
5456+
},
5457+
"BootstrapBlazor.Shared.Demos.Table.TablesSelection.TablesSelectionNormal": {
5458+
"TablesSelectionNormalTips": "保持行状态回落机制,<code>ModelEqualityComparer</code> <code>CustomKeyAttribute</code> <code>IEqualityComparer&lt;TItem&gt;</code> <code>Equals</code> 重载方法",
5459+
"TablesSelectionNormalSelectRow": "选中的行记录",
5460+
"TablesSelectionNormalButtonText": "清除选择"
54595461
},
54605462
"BootstrapBlazor.Shared.Samples.Table.TablesExcel": {
54615463
"H1": "Table 表格",
Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
11
@page "/tables/selection"
2+
@inject IStringLocalizer<TablesSelection> Localizer
23

3-
<h3>@Localizer["H1"]</h3>
4-
<h4>@((MarkupString)Localizer["H2"].Value)</h4>
4+
<h3>@Localizer["TablesSelectionTitle"]</h3>
5+
<h4>@((MarkupString)Localizer["TablesSelectionDescription"].Value)</h4>
56

6-
<DemoBlock Title="@Localizer["P1"]" Introduction="@Localizer["P2"]" Name="SelectedRow">
7-
<Table TItem="Foo" @bind-SelectedRows="SelectedItems"
8-
IsPagination="true" PageItemsSource="@PageItemsSource"
9-
IsStriped="true" IsBordered="true" IsMultipleSelect="true"
10-
ShowToolbar="true" ShowDefaultButtons="false" OnQueryAsync="@OnQueryAsync">
11-
<TableColumns>
12-
<TableColumn @bind-Field="@context.DateTime" Width="180" />
13-
<TableColumn @bind-Field="@context.Name" Width="100" />
14-
<TableColumn @bind-Field="@context.Address" />
15-
<TableColumn @bind-Field="@context.Count" />
16-
</TableColumns>
17-
</Table>
7+
<DemoBlock Title="@Localizer["TablesSelectionNormalTitle"]"
8+
Introduction="@Localizer["TablesSelectionNormalIntro"]"
9+
Name="Normal"
10+
Demo="typeof(Demos.Table.TablesSelection.TablesSelectionNormal)">
1811
</DemoBlock>
1912

20-
<Tips class="mt-3">
21-
<div>@((MarkupString)Localizer["P3"].Value)</div>
22-
</Tips>
23-
24-
<p class="mt-3">@Localizer["P4"]:</p>
25-
<ul class="ul-demo mb-3">
26-
@foreach (var item in SelectedItems)
27-
{
28-
<li>@item.Name</li>
29-
}
30-
</ul>
31-
32-
<Button OnClick="OnClick" Color="Color.Primary">@Localizer["P5"]</Button>

src/BootstrapBlazor.Shared/Samples/Table/TablesSelection.razor.cs

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)