Skip to content

Commit 91a31b5

Browse files
authored
refactor: update table resize support fix header (#2416)
* feat: 支持固定表头模式 * doc: 更新示例
1 parent bbdda26 commit 91a31b5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
Introduction="@Localizer["AllowResizingIntro"]"
4646
Name="AllowResizing">
4747
<section ignore class="mb-3">@((MarkupString)Localizer["AllowResizingDesc"].Value)</section>
48-
<Table TItem="Foo"
48+
<Table TItem="Foo" IsFixedHeader="true"
4949
IsPagination="true" PageItemsSource="@PageItemsSource"
5050
AllowResizing="true" ClientTableName="table-test"
5151
IsStriped="true" IsBordered="true" RenderMode="TableRenderMode.Table"

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,16 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
832832

833833
private int? _localStorageTableWidth;
834834

835-
private string? GetTableStyleString(bool hasHeader) => hasHeader && _localStorageTableWidth.HasValue
836-
? $"width: {_localStorageTableWidth.Value}px;"
837-
: null;
835+
private string? GetTableStyleString(bool hasHeader)
836+
{
837+
string? ret = null;
838+
if (_localStorageTableWidth.HasValue)
839+
{
840+
var width = hasHeader ? _localStorageTableWidth.Value : _localStorageTableWidth.Value - 6;
841+
ret = $"width: {width}px;";
842+
}
843+
return ret;
844+
}
838845

839846
private string? GetTableName(bool hasHeader) => hasHeader ? ClientTableName : null;
840847

0 commit comments

Comments
 (0)