Skip to content

Commit 80ef17d

Browse files
committed
refactor: 更新扩展方法
1 parent 47a5845 commit 80ef17d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/BootstrapBlazor/Components/Filters/TableFilter.razor.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public partial class TableFilter : IFilter
4747
/// 获得/设置 ITable 实例
4848
/// </summary>
4949
[Parameter]
50+
[NotNull]
5051
public ITable? Table { get; set; }
5152

5253
/// <summary>
@@ -76,11 +77,6 @@ public partial class TableFilter : IFilter
7677
[NotNull]
7778
public IFilterAction? FilterAction { get; set; }
7879

79-
/// <summary>
80-
/// 获得 当前过滤条件是否激活
81-
/// </summary>
82-
internal bool HasFilter => (Table != null) && Table.Filters.ContainsKey(Column.GetFieldName());
83-
8480
private string _fieldKey = "";
8581

8682
/// <summary>
@@ -120,7 +116,7 @@ protected override async Task InvokeInitAsync()
120116
/// 过滤数据方法
121117
/// </summary>
122118
/// <returns></returns>
123-
internal async Task OnFilterAsync()
119+
public async Task OnFilterAsync()
124120
{
125121
if (Table != null)
126122
{

src/BootstrapBlazor/Extensions/TableFilterExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,12 @@ namespace BootstrapBlazor.Components;
77

88
internal static class TableFilterExtensions
99
{
10-
public static bool HasFilter(this TableFilter? filter) => filter?.HasFilter ?? false;
10+
public static bool HasFilter(this TableFilter? filter)
11+
{
12+
if (filter == null)
13+
{
14+
return false;
15+
}
16+
return filter.Table.Filters.ContainsKey(filter.Column.GetFieldName());
17+
}
1118
}

0 commit comments

Comments
 (0)