Skip to content

Commit 8478f2d

Browse files
committed
refactor: 增加 CheckboxColumnCompactWidth 参数
1 parent f6e86d1 commit 8478f2d

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
@@ -175,7 +175,10 @@ private int MultipleSelectColumnLeft()
175175

176176
private string? MultiColumnStyleString => GetFixedMultipleSelectColumn ? $"left: {MultipleSelectColumnLeft()}px;" : null;
177177

178-
private int MultiColumnWidth => ShowCheckboxText ? ShowCheckboxTextColumnWidth : CheckboxColumnWidth;
178+
private int MultiColumnWidth => ShowCheckboxText ? ShowCheckboxTextColumnWidth :
179+
TableSize == TableSize.Normal
180+
? CheckboxColumnWidth
181+
: CheckboxColumnCompactWidth;
179182

180183
/// <summary>
181184
/// 获得指定列头固定列样式
@@ -290,7 +293,10 @@ private int CalcMargin()
290293
}
291294
if (IsMultipleSelect)
292295
{
293-
margin += ShowCheckboxText ? ShowCheckboxTextColumnWidth : CheckboxColumnWidth;
296+
margin += ShowCheckboxText ? ShowCheckboxTextColumnWidth :
297+
TableSize == TableSize.Normal
298+
? CheckboxColumnWidth
299+
: CheckboxColumnCompactWidth;
294300
}
295301
if (ShowLineNo)
296302
{

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ private string GetSortTooltip(ITableColumn col) => SortName != col.GetFieldName(
339339
[Parameter]
340340
public int CheckboxColumnWidth { get; set; }
341341

342+
/// <summary>
343+
/// 获得/设置 紧凑模式下复选框宽度 默认 28
344+
/// </summary>
345+
[Parameter]
346+
public int CheckboxColumnCompactWidth { get; set; }
347+
342348
/// <summary>
343349
/// 获得/设置 行号列宽度 默认 60
344350
/// </summary>
@@ -877,9 +883,12 @@ private void OnInitParameters()
877883

878884
if (CheckboxColumnWidth == 0)
879885
{
880-
CheckboxColumnWidth = TableSize == TableSize.Normal
881-
? op.TableSettings.CheckboxColumnWidth
882-
: op.TableSettings.CheckboxColumnCompactWidth;
886+
CheckboxColumnWidth = op.TableSettings.CheckboxColumnWidth;
887+
}
888+
889+
if (CheckboxColumnCompactWidth == 0)
890+
{
891+
CheckboxColumnCompactWidth = op.TableSettings.CheckboxColumnCompactWidth;
883892
}
884893

885894
if (op.TableSettings.TableRenderMode != null && RenderMode == TableRenderMode.Auto)

0 commit comments

Comments
 (0)