From 67cc5779602a41f68b85980e20357395bcf04f07 Mon Sep 17 00:00:00 2001 From: Argo Date: Sun, 9 Jan 2022 09:34:23 +0000 Subject: [PATCH] =?UTF-8?q?!2298=20feat(#I4Q03I):=20add=20OnSort=20action?= =?UTF-8?q?=20on=20Table=20component=20*=20refactor:=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=20Table=20=E7=BB=84=E4=BB=B6=20OnSort=20=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=A7=94=E6=89=98=20*=20feat:=20=E5=8A=A8=E6=80=81=E5=A4=9A?= =?UTF-8?q?=E5=88=97=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.Sort.cs | 14 +++++++--- .../Components/Table/Table.razor.cs | 27 ++++++++++++++++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs index 0123ce950..349ee4077 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs @@ -50,10 +50,16 @@ public partial class Table public List? SortList { get; set; } /// - /// 获得/设置 表头排序时回调方法 + /// 获得/设置 点击表头排序时回调方法 + /// + [Parameter] + public Action? OnSort { get; set; } + + /// + /// 获得/设置 内部表头排序时回调方法 /// [NotNull] - protected Func? OnSortAsync { get; set; } + protected Func? IntenralOnSortAsync { get; set; } /// /// 点击列进行排序方法 @@ -76,9 +82,9 @@ public partial class Table SortName = col.GetFieldName(); // 通知 Table 组件刷新数据 - if (OnSortAsync != null) + if (IntenralOnSortAsync != null) { - await OnSortAsync(); + await IntenralOnSortAsync(SortName, SortOrder); } }; diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.cs b/src/BootstrapBlazor/Components/Table/Table.razor.cs index c5d19ad54..13ef3d046 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.cs @@ -659,7 +659,14 @@ public partial class Table : BootstrapComponentBase, IDisposable, ITable Interop = new JSInterop>(JSRuntime); // 设置 OnSort 回调方法 - OnSortAsync = QueryAsync; + IntenralOnSortAsync = async (sortName, sortOrder) => + { + // 调用 OnSort 回调方法 + OnSort?.Invoke(sortName, SortOrder); + + // 重新查询 + await QueryAsync(); + }; // 设置 OnFilter 回调方法 OnFilterAsync = async () => @@ -1116,9 +1123,21 @@ public partial class Table : BootstrapComponentBase, IDisposable, ITable private int GetColumnCount() { var colspan = ColumnVisibles.Count(col => col.Visible); - if (IsMultipleSelect) colspan++; - if (ShowLineNo) colspan++; - if (ShowExtendButtons) colspan++; + if (IsMultipleSelect) + { + colspan++; + } + + if (ShowLineNo) + { + colspan++; + } + + if (ShowExtendButtons) + { + colspan++; + } + return colspan; }