diff --git a/.editorconfig b/.editorconfig
index 04875a7e0b393301fb01e45ddb2e6790835e5338..4a2590edd1ee9228b2a329fe216f1ccc421b5687 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -64,8 +64,8 @@ dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
-dotnet_prefer_inferred_tuple_names = true:suggestion
-dotnet_prefer_inferred_anonymous_type_member_names = true:suggestion
+dotnet_style_prefer_inferred_tuple_names = true:suggestion
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
diff --git a/NuGet.Config b/NuGet.Config
index 93ead7f9a193acb5c519545571e1dc77ac5ebe4a..e8e354d1fac3888bec659d459bb1f22b24f54501 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -1,7 +1,8 @@
-
+
+
diff --git a/src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesColumn.razor b/src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesColumn.razor
index 7819c8ef8790c5b5e8e767a91c3926c71dd80dd1..450a3b756eae1819ae467f6257a07fad510970e7 100644
--- a/src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesColumn.razor
+++ b/src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesColumn.razor
@@ -1,6 +1,4 @@
-@using Foo = BootstrapBlazor.Shared.Pages.Components.Foo
-@inherits TablesBaseColumn
-@page "/tables/column"
+@page "/tables/column"
Table 表格
diff --git a/src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesBaseColumn.cs b/src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesColumn.razor.cs
similarity index 40%
rename from src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesBaseColumn.cs
rename to src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesColumn.razor.cs
index 8d93032d88adc081cbb86fa462ff525546403a5c..30cdee718dd576a8848862e1f114f29f1f653c6b 100644
--- a/src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesBaseColumn.cs
+++ b/src/BootstrapBlazor.Shared/Pages/Samples/Table/TablesColumn.razor.cs
@@ -4,62 +4,126 @@
using BootstrapBlazor.Components;
using BootstrapBlazor.Shared.Pages.Components;
+using Microsoft.AspNetCore.Components;
+using Microsoft.Extensions.Localization;
+using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
-namespace BootstrapBlazor.Shared.Pages
+namespace BootstrapBlazor.Shared.Pages.Table
{
///
- ///
+ /// Table 组件列属性示例代码
///
- public abstract class TablesBaseColumn : TablesBaseQuery
+ public partial class TablesColumn
{
+ private static readonly ConcurrentDictionary, string, SortOrder, IEnumerable>> SortLambdaCache = new();
+
+ [NotNull]
+ private List? Items { get; set; }
+
+ [Inject]
+ [NotNull]
+ private IStringLocalizer? Localizer { get; set; }
+
+ [Inject]
+ [NotNull]
+ private ToastService? ToastService { get; set; }
+ private static IEnumerable PageItemsSource => new int[] { 4, 10, 20 };
+
+ ///
+ /// OnInitialized 方法
+ ///
+ protected override void OnInitialized()
+ {
+ base.OnInitialized();
+
+ Items = Foo.GenerateFoo(Localizer);
+ }
+
///
///
///
///
///
- protected Task IntFormatter(object? d)
+ protected static Task IntFormatter(object? d)
{
var data = (int?)d;
return Task.FromResult(data?.ToString("0.00") ?? "");
}
+ private Task> OnQueryAsync(QueryPageOptions options)
+ {
+ IEnumerable items = Items;
+
+ // 过滤
+ var isFiltered = false;
+ if (options.Filters.Any())
+ {
+ items = items.Where(options.Filters.GetFilterFunc());
+ isFiltered = true;
+ }
+
+ // 排序
+ var isSorted = false;
+ if (!string.IsNullOrEmpty(options.SortName))
+ {
+ var invoker = SortLambdaCache.GetOrAdd(typeof(Foo), key => LambdaExtensions.GetSortLambda().Compile());
+ items = invoker(items, options.SortName, options.SortOrder);
+ isSorted = true;
+ }
+
+ // 设置记录总数
+ var total = items.Count();
+
+ // 内存分页
+ items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems).ToList();
+
+ return Task.FromResult(new QueryData()
+ {
+ Items = items,
+ TotalCount = total,
+ IsSorted = isSorted,
+ IsFiltered = isFiltered,
+ IsSearch = true
+ });
+ }
+
///
///
///
///
- protected Task CustomerButton(IEnumerable items)
+ protected async Task CustomerButton(IEnumerable items)
{
var cate = ToastCategory.Information;
var title = "自定义按钮处理方法";
var content = $"通过不同的函数区分按钮处理逻辑,参数 Items 为 Table 组件中选中的行数据集合,当前选择数据 {items.Count()} 条";
- ToastService?.Show(new ToastOption()
+ await ToastService.Show(new ToastOption()
{
Category = cate,
Title = title,
Content = content
});
- return Task.CompletedTask;
}
///
///
///
///
- protected Task OnRowButtonClick(Foo item)
+ protected async Task OnRowButtonClick(Foo item)
{
var cate = ToastCategory.Success;
var title = "行内按钮处理方法";
var content = "通过不同的函数区分按钮处理逻辑,参数 Item 为当前行数据";
- ToastService?.Show(new ToastOption()
+ await ToastService.Show(new ToastOption()
{
Category = cate,
Title = title,
Content = content
});
- return Task.CompletedTask;
}
}
}