diff --git a/Components/Pages/Index.razor b/Components/Pages/Index.razor index fdb1c630cc910a3116ebbf09efae246494d95b7f..ce2e77dd2151ed93912ec2d3c7c5579309539a15 100644 --- a/Components/Pages/Index.razor +++ b/Components/Pages/Index.razor @@ -13,12 +13,7 @@
- - - - - - +
diff --git a/Components/Pages/Index.razor.cs b/Components/Pages/Index.razor.cs index d1b139781971fe40e997c10d1b294efd117da6f0..778f1e4b5d5277311dc46c161371ece110e61683 100644 --- a/Components/Pages/Index.razor.cs +++ b/Components/Pages/Index.razor.cs @@ -7,7 +7,6 @@ using BootstrapBlazorApp.Server.Data; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Localization; using System.Diagnostics.CodeAnalysis; -using System.Reflection; namespace BootstrapBlazorApp.Server.Components.Pages { @@ -22,8 +21,6 @@ namespace BootstrapBlazorApp.Server.Components.Pages private static IEnumerable PageItemsSource => [10, 20, 50]; - private Client? _selectClient; - private Task> OnQueryAsync(QueryPageOptions options) { if (Items == null) @@ -52,42 +49,5 @@ namespace BootstrapBlazorApp.Server.Components.Pages IsSearch = true }); } - - private static string? GetClientNameCallback(Client dto) - { - return dto.ClientName; - } - - private Task> OnClientsQueryAsync(QueryPageOptions options) - { - IEnumerable items = new List { - new() { ClientId=1,ClientName="测试一" }, - new() { ClientId=2,ClientName="测试二" }, - new() { ClientId=3,ClientName="测试三" }, - new() { ClientId=4,ClientName="测试四" }, - new() { ClientId=5,ClientName="测试五" }, - }; - - if (!string.IsNullOrEmpty(options.SortName)) - { - items = items.Sort(options.SortName, options.SortOrder); - } - - var count = items.Count(); - if (options.IsPage) - { - items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems); - } - - return Task.FromResult(new QueryData() - { - Items = items.ToList(), - TotalCount = count, - IsAdvanceSearch = true, - IsFiltered = true, - IsSearch = true, - IsSorted = true - }); - } } } diff --git a/Components/Pages/TestDemo.razor b/Components/Pages/TestDemo.razor new file mode 100644 index 0000000000000000000000000000000000000000..05b442cfe6eb584b5a554603b869d81b7921906e --- /dev/null +++ b/Components/Pages/TestDemo.razor @@ -0,0 +1,47 @@ + + + + + + + +@code { + private Client? _selectClient; + + private static string? GetClientNameCallback(Client dto) + { + return dto.ClientName; + } + + private Task> OnClientsQueryAsync(QueryPageOptions options) + { + IEnumerable items = new List { + new() { ClientId=1,ClientName="测试一" }, + new() { ClientId=2,ClientName="测试二" }, + new() { ClientId=3,ClientName="测试三" }, + new() { ClientId=4,ClientName="测试四" }, + new() { ClientId=5,ClientName="测试五" }, + }; + + if (!string.IsNullOrEmpty(options.SortName)) + { + items = items.Sort(options.SortName, options.SortOrder); + } + + var count = items.Count(); + if (options.IsPage) + { + items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems); + } + + return Task.FromResult(new QueryData() + { + Items = items.ToList(), + TotalCount = count, + IsAdvanceSearch = true, + IsFiltered = true, + IsSearch = true, + IsSorted = true + }); + } +}