Skip to content

Commit 00e9170

Browse files
doc(Table): add sample code for row span (#5080)
* doc: 增加 MergeTableRow 示例 * doc: 增加行合并示例 Co-Authored-By: Alex chow <[email protected]>
1 parent 9864a4f commit 00e9170

File tree

5 files changed

+85
-5
lines changed

5 files changed

+85
-5
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@if (Context.Row.Id == 1)
2+
{
3+
<tr>
4+
<td rowspan="4">@Context.Row.DateTime</td>
5+
<td>@Context.Row.Name</td>
6+
<td>@Context.Row.Address</td>
7+
<td>@Context.Row.Count</td>
8+
</tr>
9+
}
10+
else if (Context.Row.Id == 2)
11+
{
12+
<tr>
13+
<td rowspan="3">@Context.Row.Name</td>
14+
<td>@Context.Row.Address</td>
15+
<td>@Context.Row.Count</td>
16+
</tr>
17+
}
18+
else if (Context.Row.Id == 3)
19+
{
20+
<tr>
21+
<td rowspan="2">@Context.Row.Address</td>
22+
<td>@Context.Row.Count</td>
23+
</tr>
24+
}
25+
else if (Context.Row.Id == 4)
26+
{
27+
<tr>
28+
<td>@Context.Row.Count</td>
29+
</tr>
30+
}
31+
else
32+
{
33+
<tr>
34+
<td>@Context.Row.DateTime</td>
35+
<td>@Context.Row.Name</td>
36+
<td>@Context.Row.Address</td>
37+
<td>@Context.Row.Count</td>
38+
</tr>
39+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Server.Components.Components;
7+
8+
/// <summary>
9+
/// 自定义行组件
10+
/// </summary>
11+
public partial class MergeTableRow
12+
{
13+
/// <summary>
14+
/// 获得/设置 行上下文数据实例
15+
/// </summary>
16+
[Parameter]
17+
[NotNull]
18+
public TableRowContext<Foo>? Context { get; set; }
19+
}

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,25 @@
146146
<DemoBlock Title="@Localizer["RowTemplateTitle"]"
147147
Introduction="@Localizer["RowTemplateIntro"]"
148148
Name="RowTemplate">
149-
<section ignore>@((MarkupString)Localizer["RowTemplateDesc"].Value)</section>
149+
<Table TItem="Foo" IsPagination="true" PageItemsSource="@PageItemsSource" class="table-row-template"
150+
IsStriped="true" IsBordered="true"
151+
OnQueryAsync="@OnQueryAsync">
152+
<TableColumns>
153+
<TableColumn @bind-Field="@context.DateTime" Width="180" />
154+
<TableColumn @bind-Field="@context.Name" Width="100" />
155+
<TableColumn @bind-Field="@context.Address" />
156+
<TableColumn @bind-Field="@context.Count" />
157+
</TableColumns>
158+
<RowTemplate>
159+
<MergeTableRow Context="@context"></MergeTableRow>
160+
</RowTemplate>
161+
</Table>
162+
</DemoBlock>
163+
164+
<DemoBlock Title="@Localizer["RowContentTemplateTitle"]"
165+
Introduction="@Localizer["RowContentTemplateIntro"]"
166+
Name="RowContentTemplate">
167+
<section ignore>@((MarkupString)Localizer["RowContentTemplateDesc"].Value)</section>
150168

151169
<Table TItem="Foo" IsPagination="true" PageItemsSource="@PageItemsSource" class="table-row-template"
152170
IsStriped="true" IsBordered="true"

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5528,9 +5528,11 @@
55285528
"ClickToSelectP3": "Currently selected row:",
55295529
"ClickToSelectNoneText": "None",
55305530
"PlaceHolder": "Cannot be empty, within 50 characters",
5531+
"RowContentTemplateTitle": "Row Content Template",
5532+
"RowContentTemplateIntro": "By setting the <code>RowContentTemplate</code> template, you can implement custom row cell linkage logic by sub-packaging components to achieve performance optimization and avoid the problem of refreshing the entire table component after linkage due to cell data refresh.",
5533+
"RowContentTemplateDesc": "In this example, a custom component is used to select a date, link the quantity column, randomly generate a random number, and save it to the original data, so there is no need to refresh the entire <code>Table</code> component.",
55315534
"RowTemplateTitle": "Row Template",
5532-
"RowTemplateIntro": "By setting the <code>RowTemplate</code> template, you can implement custom row cell linkage logic by sub-packaging components to achieve performance optimization and avoid the problem of refreshing the entire table component after linkage due to cell data refresh.",
5533-
"RowTemplateDesc": "In this example, a custom component is used to select a date, link the quantity column, randomly generate a random number, and save it to the original data, so there is no need to refresh the entire <code>Table</code> component."
5535+
"RowTemplateIntro": "By setting the <code>RowTemplate</code> template, you can implement the row merging function according to your own business logic"
55345536
},
55355537
"BootstrapBlazor.Server.Components.Samples.Table.TablesDynamic": {
55365538
"TablesDynamicTitle": "Table Dynamic",

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5528,9 +5528,11 @@
55285528
"ClickToSelectP3": "当前选中行:",
55295529
"ClickToSelectNoneText": "",
55305530
"PlaceHolder": "不可为空,50字以内",
5531+
"RowContentTemplateTitle": "行内容模板",
5532+
"RowContentTemplateIntro": "通过设置 <code>RowContentTemplate</code> 模板,可通过分装组件的方式实现自定义行内单元格联动逻辑,达到性能最优化,避免单元格数据刷新导致联动后需要刷新整个表格组件的问题,可用于销售类软件,调整单价时总价列变化需求",
5533+
"RowContentTemplateDesc": "本例中通过自定义组件,实现选择日期后,联动数量列,随机生成一个随机数字,并且保存到原始数据中,从而不需要刷新整个 <code>Table</code> 组件",
55315534
"RowTemplateTitle": "行模板",
5532-
"RowTemplateIntro": "通过设置 <code>RowTemplate</code> 模板,可通过分装组件的方式实现自定义行内单元格联动逻辑,达到性能最优化,避免单元格数据刷新导致联动后需要刷新整个表格组件的问题,可用于销售类软件,调整单价时总价列变化需求",
5533-
"RowTemplateDesc": "本例中通过自定义组件,实现选择日期后,联动数量列,随机生成一个随机数字,并且保存到原始数据中,从而不需要刷新整个 <code>Table</code> 组件"
5535+
"RowTemplateIntro": "通过设置 <code>RowTemplate</code> 模板,可以根据自己的业务逻辑实现行合并功能"
55345536
},
55355537
"BootstrapBlazor.Server.Components.Samples.Table.TablesDynamic": {
55365538
"TablesDynamicTitle": "Table 表格",

0 commit comments

Comments
 (0)