diff --git a/src/BootstrapBlazor.Server/Components/Samples/Table/Tables.razor b/src/BootstrapBlazor.Server/Components/Samples/Table/Tables.razor index b712a93e8c0..28d8edaff8d 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Table/Tables.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/Table/Tables.razor @@ -1,4 +1,4 @@ -@page "/table" +@page "/table" @inject IStringLocalizer NavMenuLocalizer @inject IStringLocalizer Localizer @inject IStringLocalizer FooLocalizer @@ -7,11 +7,11 @@

@Localizer["TableBaseDescription"]

-

表格功能比较多,参数也非常多,示例更多,各个功能详细用法建议查看下方视频讲解 鞠佬 有专门的视频讲解

- +

表格功能比较多,参数也非常多,示例更多,各个功能详细用法建议查看下方视频讲解 鞠佬 有专门的视频讲解

+
@@ -68,8 +68,16 @@ -
@((MarkupString)Localizer["TableBaseSizeDescription"].Value)
- +
+

@((MarkupString)Localizer["TableBaseSizeDescription"].Value)

+
+
+ +
+
+
+
diff --git a/src/BootstrapBlazor.Server/Components/Samples/Table/Tables.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Table/Tables.razor.cs index e28114d9e4a..ffa49a9b151 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Table/Tables.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Table/Tables.razor.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone @@ -21,6 +21,8 @@ public partial class Tables [NotNull] private string? RefreshText { get; set; } + private bool _isCompact = true; + /// /// OnInitialized /// diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 5bafea74269..88b8c9ef786 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,11 +1,11 @@ - + - 9.12.2-beta01 + 9.12.2-beta02 - 10.0.0-rc.2.2.3 + 10.0.0-rc.2.2.4 diff --git a/src/BootstrapBlazor/Components/ErrorLogger/ErrorLogger.cs b/src/BootstrapBlazor/Components/ErrorLogger/ErrorLogger.cs index 589ed2932c7..133113f3f38 100644 --- a/src/BootstrapBlazor/Components/ErrorLogger/ErrorLogger.cs +++ b/src/BootstrapBlazor/Components/ErrorLogger/ErrorLogger.cs @@ -102,9 +102,9 @@ protected override async Task OnInitializedAsync() protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenComponent>(0); - builder.AddAttribute(1, nameof(CascadingValue.Value), this); - builder.AddAttribute(2, nameof(CascadingValue.IsFixed), true); - builder.AddAttribute(3, nameof(CascadingValue.ChildContent), RenderContent); + builder.AddAttribute(1, nameof(CascadingValue<>.Value), this); + builder.AddAttribute(2, nameof(CascadingValue<>.IsFixed), true); + builder.AddAttribute(3, nameof(CascadingValue<>.ChildContent), RenderContent); builder.CloseComponent(); } diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs index 1308365f1d4..4475f3eeb6f 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone @@ -175,7 +175,10 @@ private int MultipleSelectColumnLeft() private string? MultiColumnStyleString => GetFixedMultipleSelectColumn ? $"left: {MultipleSelectColumnLeft()}px;" : null; - private int MultiColumnWidth => ShowCheckboxText ? ShowCheckboxTextColumnWidth : CheckboxColumnWidth; + private int MultiColumnWidth => ShowCheckboxText ? ShowCheckboxTextColumnWidth : + TableSize == TableSize.Normal + ? CheckboxColumnWidth + : CheckboxColumnCompactWidth; /// /// 获得指定列头固定列样式 @@ -290,7 +293,10 @@ private int CalcMargin() } if (IsMultipleSelect) { - margin += ShowCheckboxText ? ShowCheckboxTextColumnWidth : CheckboxColumnWidth; + margin += ShowCheckboxText ? ShowCheckboxTextColumnWidth : + TableSize == TableSize.Normal + ? CheckboxColumnWidth + : CheckboxColumnCompactWidth; } if (ShowLineNo) { diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.cs b/src/BootstrapBlazor/Components/Table/Table.razor.cs index e2c4aad5be5..da31d71752d 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone @@ -339,6 +339,12 @@ private string GetSortTooltip(ITableColumn col) => SortName != col.GetFieldName( [Parameter] public int CheckboxColumnWidth { get; set; } + /// + /// 获得/设置 紧凑模式下复选框宽度 默认 28 + /// + [Parameter] + public int CheckboxColumnCompactWidth { get; set; } + /// /// 获得/设置 行号列宽度 默认 60 /// @@ -880,6 +886,11 @@ private void OnInitParameters() CheckboxColumnWidth = op.TableSettings.CheckboxColumnWidth; } + if (CheckboxColumnCompactWidth == 0) + { + CheckboxColumnCompactWidth = op.TableSettings.CheckboxColumnCompactWidth; + } + if (op.TableSettings.TableRenderMode != null && RenderMode == TableRenderMode.Auto) { RenderMode = op.TableSettings.TableRenderMode.Value; diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.scss b/src/BootstrapBlazor/Components/Table/Table.razor.scss index e7625b6ff92..fd64dcd2d88 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.scss +++ b/src/BootstrapBlazor/Components/Table/Table.razor.scss @@ -1,4 +1,4 @@ -.table-container { +.table-container { --bb-table-td-padding-x: .5rem; --bb-table-td-padding-y: .5rem; --bb-table-cardview-label-width: 30%; @@ -72,7 +72,7 @@ } .table-sm { - --bb-table-td-padding-x: .25rem; + --bb-table-td-padding-x: .35rem; --bb-table-td-padding-y: .25rem; } diff --git a/src/BootstrapBlazor/Options/TableSettings.cs b/src/BootstrapBlazor/Options/TableSettings.cs index 1004b2bd2ea..bfbf8ed3c8f 100644 --- a/src/BootstrapBlazor/Options/TableSettings.cs +++ b/src/BootstrapBlazor/Options/TableSettings.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone @@ -15,6 +15,11 @@ public class TableSettings /// public int CheckboxColumnWidth { get; set; } = 36; + /// + /// 获得/设置 复选框宽度 默认 28 + /// + public int CheckboxColumnCompactWidth { get; set; } = 28; + /// /// 获得/设置 明细行 Row Header 宽度 默认 24 /// diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs index c565a36f2ca..b30d56badb1 100644 --- a/test/UnitTest/Components/TableTest.cs +++ b/test/UnitTest/Components/TableTest.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone @@ -1731,7 +1731,7 @@ public void FixedColumn_Ok() builder.OpenComponent>(0); builder.AddAttribute(1, "Field", foo.Name); builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string))); - builder.AddAttribute(3, nameof(TableColumn.Fixed), true); + builder.AddAttribute(3, nameof(TableColumn<,>.Fixed), true); builder.CloseComponent(); }); pb.Add(a => a.DetailRowTemplate, foo => builder => @@ -1972,6 +1972,13 @@ public void FixedMultipleColumn_Ok() }); }); Assert.Contains("left: 36px;", cut.Markup); + + var table = cut.FindComponent>(); + table.SetParametersAndRender(pb => + { + pb.Add(a => a.TableSize, TableSize.Compact); + }); + Assert.Contains("left: 28px;", cut.Markup); } [Theory] @@ -2650,7 +2657,7 @@ public void ToolbarButton_Ok() pb.Add(a => a.TableToolbarTemplate, builder => { builder.OpenComponent>(0); - builder.AddAttribute(1, nameof(TableToolbarButton.Text), "test-after"); + builder.AddAttribute(1, nameof(TableToolbarButton<>.Text), "test-after"); builder.CloseComponent(); }); pb.Add(a => a.TableToolbarBeforeTemplate, builder => @@ -3257,6 +3264,30 @@ public void ShowFilterHeader_Ok(bool showCheckboxText) }); }); }); + + if (showCheckboxText == false) + { + cut.Contains("width: 36px;"); + } + else + { + cut.Contains("width: 80px;"); + } + + var table = cut.FindComponent>(); + table.SetParametersAndRender(pb => + { + pb.Add(a => a.TableSize, TableSize.Compact); + }); + + if (showCheckboxText == false) + { + cut.Contains("width: 28px;"); + } + else + { + cut.Contains("width: 80px;"); + } } [Theory] @@ -7390,6 +7421,7 @@ public void TableSize_Ok() { pb.Add(a => a.RenderMode, TableRenderMode.Table); pb.Add(a => a.TableSize, TableSize.Normal); + pb.Add(a => a.IsMultipleSelect, true); pb.Add(a => a.OnQueryAsync, OnQueryAsync(localizer)); pb.Add(a => a.TableColumns, foo => builder => {