Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.11.2-beta02</Version>
<Version>9.11.2-beta03</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ private async Task OnTableRenderAsync(bool firstRender)
{
DragColumnCallback = nameof(DragColumnCallback),
AutoFitColumnWidthCallback = OnAutoFitColumnWidthCallback == null ? null : nameof(AutoFitColumnWidthCallback),
FitColumnWidthIncludeHeader,
ResizeColumnCallback = OnResizeColumnAsync != null ? nameof(ResizeColumnCallback) : null,
ColumnMinWidth = ColumnMinWidth ?? Options.CurrentValue.TableSettings.ColumnMinWidth,
ScrollWidth = ActualScrollWidth,
Expand Down Expand Up @@ -1598,6 +1599,12 @@ private async Task OnContextMenu(MouseEventArgs e, TItem item)
[Parameter]
public Func<string, float, Task<float>>? OnAutoFitColumnWidthCallback { get; set; }

/// <summary>
/// 获得/设置 列宽自适应时是否包含表头 默认 false
/// </summary>
[Parameter]
public bool FitColumnWidthIncludeHeader { get; set; }

/// <summary>
/// 列宽自适应方法
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,12 @@ const autoFitColumnWidth = async (table, col) => {
maxWidth = Math.max(maxWidth, calcCellWidth(cell));
});

if (table.options.fitColumnWidthIncludeHeader) {
const th = col.closest('th');
const span = th.querySelector('.table-cell');
maxWidth = Math.max(maxWidth, calcCellWidth(span));
}

if (table.options.autoFitColumnWidthCallback !== null) {
const widthValue = await table.invoke.invokeMethodAsync(table.options.autoFitColumnWidthCallback, field, maxWidth);
if (widthValue > 0) {
Expand Down
Loading