Skip to content

Commit 57355cb

Browse files
committed
refactor: 支持默认值
1 parent 3a2de91 commit 57355cb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/BootstrapBlazor/Components/Filters/LookupFilter.razor.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,29 @@ public partial class LookupFilter
1818
/// <summary>
1919
/// <inheritdoc/>
2020
/// </summary>
21-
protected override void OnParametersSet()
21+
protected override async Task OnParametersSetAsync()
2222
{
23-
base.OnParametersSet();
23+
await base.OnParametersSetAsync();
2424

2525
if (TableColumnFilter != null)
2626
{
2727
var column = TableColumnFilter.Column;
2828
_isShowSearch = column.ShowSearchWhenSelect;
2929
_type = column.PropertyType;
3030
_lookup = column;
31+
32+
if (string.IsNullOrEmpty(_value))
33+
{
34+
var service = _lookup.LookupService;
35+
if (service != null)
36+
{
37+
var items = await _lookup.GetItemsAsync(service, _lookup.LookupServiceKey, _lookup.LookupServiceData);
38+
if(items != null)
39+
{
40+
_value = items.FirstOrDefault()?.Value;
41+
}
42+
}
43+
}
3144
}
3245
}
3346

0 commit comments

Comments
 (0)