diff --git a/src/BootstrapBlazor.Shared/Samples/Table/TablesFooter.razor b/src/BootstrapBlazor.Shared/Samples/Table/TablesFooter.razor index 70b0252181704498a0c1f427f6297232261c32fa..b183115d7e816b8a3f6898400f2e280a61acd14b 100644 --- a/src/BootstrapBlazor.Shared/Samples/Table/TablesFooter.razor +++ b/src/BootstrapBlazor.Shared/Samples/Table/TablesFooter.razor @@ -60,11 +60,11 @@ diff --git a/src/BootstrapBlazor.Shared/Samples/Table/TablesFooter.razor.cs b/src/BootstrapBlazor.Shared/Samples/Table/TablesFooter.razor.cs index bbd6f94aa5976bf6063c005336f9160031091fd8..578dfbd63740d84a9552285f8c833ad5ce28965f 100644 --- a/src/BootstrapBlazor.Shared/Samples/Table/TablesFooter.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/Table/TablesFooter.razor.cs @@ -73,4 +73,8 @@ public sealed partial class TablesFooter IsSearch = true }); } + + private static double GetAverage(IEnumerable items) => items.Any() ? items.Average(i => i.Count) : 0; + + private static int GetSum(IEnumerable items) => items.Any() ? items.Sum(i => i.Count) : 0; } diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 289dc7be72a1866c875271a41427e8636067b935..48c26d66f1b83b3cfa3294add1366ae677493627 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 6.2.0 + 6.2.1 diff --git a/src/BootstrapBlazor/Components/Empty/Empty.razor b/src/BootstrapBlazor/Components/Empty/Empty.razor index 6700581a2a82133b8b754200c4d45e0558fd4ea2..0802c67189bcb25f95320091cc2bdea147e1dbfc 100644 --- a/src/BootstrapBlazor/Components/Empty/Empty.razor +++ b/src/BootstrapBlazor/Components/Empty/Empty.razor @@ -2,23 +2,26 @@ @inherits BootstrapComponentBase
- @if (!string.IsNullOrEmpty(Image)) - { -
- -
- } - @if (!string.IsNullOrEmpty(Text)) - { -
- @Text -
- } @if (Template != null) {
@Template
} - @ChildContent + else + { + @if (!string.IsNullOrEmpty(Image)) + { +
+ +
+ } + @if (!string.IsNullOrEmpty(Text)) + { +
+ @Text +
+ } + @ChildContent + }
diff --git a/src/BootstrapBlazor/Components/Table/Table.razor b/src/BootstrapBlazor/Components/Table/Table.razor index 00194e9d7f6bc69f99868c84fff49e5cf66660da..a917ad80feea5545a356cfe070cd8180472ac05d 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor +++ b/src/BootstrapBlazor/Components/Table/Table.razor @@ -335,7 +335,7 @@ { - + diff --git a/src/BootstrapBlazor/Components/Table/TableFooterCell.razor.cs b/src/BootstrapBlazor/Components/Table/TableFooterCell.razor.cs index 01e2c8eecdee7e0b68e9634e6dabaa88935b9d15..2aa5fa5bbf3835ffc94e60e349e38723af7b9448 100644 --- a/src/BootstrapBlazor/Components/Table/TableFooterCell.razor.cs +++ b/src/BootstrapBlazor/Components/Table/TableFooterCell.razor.cs @@ -59,7 +59,7 @@ public partial class TableFooterCell [CascadingParameter(Name = "TableFooterContext")] private object? DataSource { get; set; } - private string? GetText() => Text ?? GetCountValue() ?? GetAggegateValue(); + private string? GetText() => Text ?? (GetCount(DataSource) == 0 ? "0" : (GetCountValue() ?? GetAggegateValue())); /// /// 解析 Count Aggregate @@ -209,5 +209,28 @@ public partial class TableFooterCell return mi?.MakeGenericMethod(modelType); } - private static int CreateCountMethod(IEnumerable source) => Enumerable.Count(source); + private static int CreateCountMethod(IEnumerable source) => source.Count(); + + private static int GetCount(object? source) + { + var ret = 0; + if (source != null) + { + // 绑定数据源类型 + var type = source.GetType(); + + // 数据源泛型 TModel 类型 + var modelType = type.GenericTypeArguments[0]; + + var mi = typeof(TableFooterCell).GetMethod(nameof(CreateCountMethod), BindingFlags.NonPublic | BindingFlags.Static) + ?.MakeGenericMethod(modelType); + + if (mi != null) + { + var v = mi.Invoke(null, new object[] { source })?.ToString(); + _ = int.TryParse(v, out ret); + } + } + return ret; + } }