mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-06 05:59:45 +08:00
!2298 feat(#I4Q03I): add OnSort action on Table component
* refactor: 重构 Table 组件 OnSort 回调委托 * feat: 动态多列排序功能
This commit is contained in:
parent
386e2a4364
commit
67cc577960
@ -50,10 +50,16 @@ public partial class Table<TItem>
|
||||
public List<string>? SortList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 表头排序时回调方法
|
||||
/// 获得/设置 点击表头排序时回调方法
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Action<string, SortOrder>? OnSort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 内部表头排序时回调方法
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
protected Func<Task>? OnSortAsync { get; set; }
|
||||
protected Func<string, SortOrder, Task>? IntenralOnSortAsync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点击列进行排序方法
|
||||
@ -76,9 +82,9 @@ public partial class Table<TItem>
|
||||
SortName = col.GetFieldName();
|
||||
|
||||
// 通知 Table 组件刷新数据
|
||||
if (OnSortAsync != null)
|
||||
if (IntenralOnSortAsync != null)
|
||||
{
|
||||
await OnSortAsync();
|
||||
await IntenralOnSortAsync(SortName, SortOrder);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -659,7 +659,14 @@ public partial class Table<TItem> : BootstrapComponentBase, IDisposable, ITable
|
||||
Interop = new JSInterop<Table<TItem>>(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<TItem> : 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user