mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 13:39:39 +08:00
!801 fix(#I2AMG2): can't open page when set OnSelectedItemChanged value on DropdownList components
* fix: change OnSelectedItemChanged to Func<TValue, Task>
This commit is contained in:
parent
30e998d968
commit
7454faae15
@ -129,6 +129,13 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
Type = "RenderFragment",
|
||||
ValueList = " — ",
|
||||
DefaultValue = " — "
|
||||
},
|
||||
new AttributeItem() {
|
||||
Name = "OnSelectedItemChanged",
|
||||
Description = "下拉框选择项改变时回调此委托",
|
||||
Type = "Func<TValue, Task>",
|
||||
ValueList = " — ",
|
||||
DefaultValue = " — "
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ namespace BootstrapBlazor.Components
|
||||
/// SelectedItemChanged 方法
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<TValue> OnSelectedItemChanged { get; set; }
|
||||
public Func<TValue, Task>? OnSelectedItemChanged { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
@ -147,6 +147,8 @@ namespace BootstrapBlazor.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (Data != null) Data = Data.ToList();
|
||||
|
||||
await base.SetParametersAsync(ParameterView.Empty);
|
||||
}
|
||||
|
||||
@ -163,9 +165,9 @@ namespace BootstrapBlazor.Components
|
||||
/// <summary>
|
||||
/// OnInitialized 方法
|
||||
/// </summary>
|
||||
protected override void OnParametersSet()
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
await base.OnParametersSetAsync();
|
||||
|
||||
// 双向绑定其他组件更改了数据源值时
|
||||
if (Data != null && CurrentItem != null && CurrentItem.ToString() != CurrentValueAsString)
|
||||
@ -193,20 +195,20 @@ namespace BootstrapBlazor.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (CurrentItem != null && OnSelectedItemChanged.HasDelegate) OnSelectedItemChanged.InvokeAsync(Value);
|
||||
if (CurrentItem != null && OnSelectedItemChanged != null) await OnSelectedItemChanged(Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下拉框选项点击时调用此方法
|
||||
/// </summary>
|
||||
protected void OnItemClick(TModel item)
|
||||
protected async Task OnItemClick(TModel item)
|
||||
{
|
||||
CurrentItem = item;
|
||||
|
||||
// ValueChanged
|
||||
CurrentValueAsString = GetValue(item);
|
||||
|
||||
if (OnSelectedItemChanged.HasDelegate) OnSelectedItemChanged.InvokeAsync(Value);
|
||||
if (OnSelectedItemChanged != null) await OnSelectedItemChanged(Value);
|
||||
}
|
||||
|
||||
#nullable disable
|
||||
|
Loading…
Reference in New Issue
Block a user