Skip to content

Commit bbdda26

Browse files
authored
doc(Table): update sample code (#2415)
* doc: 更新文档 * refactor: 更改参数名称 * doc: 更新示例 * doc: 更新资源文件 * doc: 更新示例 * refactor: 更新 loader 查找逻辑 * refactor: 更新代码逻辑 * chore: bump version 8.0.3-beta3
1 parent 512920f commit bbdda26

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@
4444
<DemoBlock Title="@Localizer["AllowResizingTitle"]"
4545
Introduction="@Localizer["AllowResizingIntro"]"
4646
Name="AllowResizing">
47-
<p class="mb-3">@((MarkupString)Localizer["AllowResizingDesc"].Value)</p>
47+
<section ignore class="mb-3">@((MarkupString)Localizer["AllowResizingDesc"].Value)</section>
4848
<Table TItem="Foo"
49-
IsPagination="true" PageItemsSource="@PageItemsSource" AllowResizing="true"
49+
IsPagination="true" PageItemsSource="@PageItemsSource"
50+
AllowResizing="true" ClientTableName="table-test"
5051
IsStriped="true" IsBordered="true" RenderMode="TableRenderMode.Table"
5152
ShowToolbar="false" IsMultipleSelect="true"
5253
OnQueryAsync="@OnQueryAsync">

src/BootstrapBlazor.Server/Locales/zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4822,7 +4822,7 @@
48224822
"WidthP3": "通过设置按钮 <code>IsShow</code> 参数来控制是否显示按钮",
48234823
"AllowResizingTitle": "允许列调整",
48244824
"AllowResizingIntro": "通过指定 <code>AllowResizing</code> 设置表格列允许调整宽度",
4825-
"AllowResizingDesc": "<b>注意:</b> <code>Table</code> 父容器有有效宽度值时 <code>Table</code> 才会出现滚动条",
4825+
"AllowResizingDesc": "<b>注意:</b> <code>Table</code> 父容器有有效宽度值时 <code>Table</code> 才会出现滚动条,可通过设置 <code>ClientTableName</code> 参数开启本地化存储列宽功能,即通过拖拽后列宽下次打开时会保持",
48264826
"WidthButtonText1": "明细",
48274827
"WidthButtonText2": "编辑",
48284828
"WidthButtonText3": "权限",

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>8.0.3-beta02</Version>
4+
<Version>8.0.3-beta03</Version>
55
</PropertyGroup>
66

77
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public void ExpandDetailRow(TItem item)
579579
/// 获得/设置 表格名称 默认 null 用于列宽持久化功能
580580
/// </summary>
581581
[Parameter]
582-
public string? TableName { get; set; }
582+
public string? ClientTableName { get; set; }
583583

584584
[CascadingParameter]
585585
[NotNull]
@@ -836,14 +836,14 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
836836
? $"width: {_localStorageTableWidth.Value}px;"
837837
: null;
838838

839-
private string? GetTableName(bool hasHeader) => hasHeader ? TableName : null;
839+
private string? GetTableName(bool hasHeader) => hasHeader ? ClientTableName : null;
840840

841841
private async Task<IEnumerable<ColumnWidth>> ReloadColumnWidth()
842842
{
843843
IEnumerable<ColumnWidth>? ret = null;
844-
if (!string.IsNullOrEmpty(TableName) && AllowResizing)
844+
if (!string.IsNullOrEmpty(ClientTableName) && AllowResizing)
845845
{
846-
var jsonData = await InvokeAsync<string>("reloadColumnWidth", Id, TableName);
846+
var jsonData = await InvokeAsync<string>("reloadColumnWidth", Id, ClientTableName);
847847
if (!string.IsNullOrEmpty(jsonData))
848848
{
849849
try

src/BootstrapBlazor/Components/Table/Table.razor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,11 @@ export function sort(id) {
579579
export function load(id, method) {
580580
const table = Data.get(id)
581581

582-
const loader = table.el.querySelector('.table-loader')
582+
const loader = [...table.el.children].find(el => el.classList.contains('table-loader'));
583583
if (method === 'show') {
584584
loader.classList.add('show')
585-
} else {
585+
}
586+
else {
586587
loader.classList.remove('show')
587588
}
588589
}

0 commit comments

Comments
 (0)