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; }