Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/BootstrapBlazor/Components/Table/Table.razor
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,10 @@
}
@if (col.GetFilterable() && !ShowFilterHeader)
{
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsActive="@Filters.ContainsKey(fieldName)" @onclick:stopPropagation></TableColumnFilter>
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsActive="@Filters.ContainsKey(fieldName)"
NotSupportedMessage="@NotSupportedMessage"
@onclick:stopPropagation>
</TableColumnFilter>
}
@if (col.GetSortable())
{
Expand Down Expand Up @@ -655,7 +658,9 @@
<div class="table-cell">
@if(col.GetFilterable())
{
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsHeaderRow="true"></TableColumnFilter>
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsHeaderRow="true"
NotSupportedMessage="@NotSupportedMessage">
</TableColumnFilter>
}
</div>
</th>
Expand Down
6 changes: 6 additions & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ namespace BootstrapBlazor.Components;
[CascadingTypeParameter(nameof(TItem))]
public partial class Table<TItem> : ITable, IModelEqualityComparer<TItem> where TItem : class
{
/// <summary>
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
/// </summary>
[Parameter]
public string? NotSupportedMessage { get; set; }

/// <summary>
/// 获得/设置 Loading 模板
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
"Contains": "Contains",
"NotContains": "NotContains",
"EnumFilter.AllText": "All",
"NotSupportedMessage": "Unsupported filter type, Please customize the filter use FilterTemplate",
"NotSupportedMessage": "Unsupported filter type, Please customize the filter use FilterTemplate, Please refer https://www.blazor.zone/table/filter#CustomFilter",
"MultiFilterSearchPlaceHolderText": "Please enter ...",
"MultiFilterSelectAllText": "Select All"
},
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
"Contains": "包含",
"NotContains": "不包含",
"EnumFilter.AllText": "全选",
"NotSupportedMessage": "不支持的类型,请使用 FilterTemplate 自定义过滤组件",
"NotSupportedMessage": "不支持的类型,请使用 FilterTemplate 自定义过滤组件,请参考文档 https://www.blazor.zone/table/filter#CustomFilter",
"MultiFilterSearchPlaceHolderText": "请输入 ...",
"MultiFilterSelectAllText": "全选"
},
Expand Down
3 changes: 2 additions & 1 deletion test/UnitTest/Components/TableNotSupportFilterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ public void OnFilterAsync_Ok()
{
var cut = Context.RenderComponent<TableColumnFilter>(pb =>
{
pb.Add(a => a.NotSupportedMessage, "不支持的类型");
pb.Add(a => a.Table, new MockTable());
pb.Add(a => a.Column, new MockColumn());
});

cut.Contains("不支持的类型,请使用 FilterTemplate 自定义过滤组件");
cut.Contains("不支持的类型");

var filter = cut.FindComponent<NotSupportFilter>();
var conditions = filter.Instance.GetFilterConditions();
Expand Down
1 change: 1 addition & 0 deletions test/UnitTest/Components/TableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ public async Task CustomSearch_Ok()
{
pb.AddChildContent<Table<Foo>>(pb =>
{
pb.Add(a => a.NotSupportedMessage, "test-not-support");
pb.Add(a => a.SearchText, "张三");
pb.Add(a => a.TableColumns, foo => builder =>
{
Expand Down