Skip to content

Commit b46eb35

Browse files
ArgoZhangeramosr16
andcommitted
feat: 增加 Lookup 支持
Co-Authored-By: Ernesto Ramos Rio <[email protected]>
1 parent c13113c commit b46eb35

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/BootstrapBlazor/Components/Table/LookupContent.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

66
using Microsoft.AspNetCore.Components.Rendering;
7-
using System.ComponentModel;
87

98
namespace BootstrapBlazor.Components;
109

1110
internal class LookupContent : ComponentBase
1211
{
12+
/// <summary>
13+
/// 获得/设置 <see cref="ILookupService"/> 服务实例
14+
/// </summary>
15+
[Parameter]
16+
public IEnumerable<SelectedItem>? Lookup { get; set; }
17+
1318
/// <summary>
1419
/// 获得/设置 <see cref="ILookupService"/> 服务实例
1520
/// </summary>
@@ -76,8 +81,16 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
7681

7782
private async Task<List<SelectedItem>> GetLookupItemsAsync()
7883
{
79-
var lookupService = LookupService ?? InjectLookupService;
80-
var items = await lookupService.GetItemsAsync(LookupServiceKey, LookupServiceData);
84+
IEnumerable<SelectedItem>? items;
85+
if (Lookup != null)
86+
{
87+
items = Lookup;
88+
}
89+
else
90+
{
91+
var lookupService = LookupService ?? InjectLookupService;
92+
items = await lookupService.GetItemsAsync(LookupServiceKey, LookupServiceData);
93+
}
8194
return items?.ToList() ?? [];
8295
}
8396
}

0 commit comments

Comments
 (0)