@@ -29,6 +29,12 @@ public partial class RadioListGeneric<TValue> : IModelEqualityComparer<TValue>
2929 [ Parameter ]
3030 public RenderFragment < SelectedItem < TValue > > ? ItemTemplate { get ; set ; }
3131
32+ /// <summary>
33+ /// 获得/设置 是否为按钮样式 默认 false
34+ /// </summary>
35+ [ Parameter ]
36+ public bool IsButton { get ; set ; }
37+
3238 /// <summary>
3339 /// 获得/设置 是否显示边框 默认为 true
3440 /// </summary>
@@ -58,7 +64,7 @@ public partial class RadioListGeneric<TValue> : IModelEqualityComparer<TValue>
5864 /// 获得/设置 SelectedItemChanged 方法
5965 /// </summary>
6066 [ Parameter ]
61- public Func < IEnumerable < SelectedItem < TValue > > , TValue , Task > ? OnSelectedChanged { get ; set ; }
67+ public Func < TValue , Task > ? OnSelectedChanged { get ; set ; }
6268
6369 /// <summary>
6470 /// 获得/设置 数据主键标识标签 默认为 <see cref="KeyAttribute"/><code><br /></code>用于判断数据主键标签,如果模型未设置主键时可使用 <see cref="ModelEqualityComparer"/> 参数自定义判断 <code><br /></code>数据模型支持联合主键
@@ -74,6 +80,13 @@ public partial class RadioListGeneric<TValue> : IModelEqualityComparer<TValue>
7480 [ Parameter ]
7581 public Func < TValue , TValue , bool > ? ModelEqualityComparer { get ; set ; }
7682
83+ /// <summary>
84+ /// 获得 当前选项是否被禁用
85+ /// </summary>
86+ /// <param name="item"></param>
87+ /// <returns></returns>
88+ private bool GetDisabledState ( SelectedItem < TValue > item ) => IsDisabled || item . IsDisabled ;
89+
7790 private string ? GroupName => Id ;
7891
7992 private string ? ClassString => CssBuilder . Default ( "radio-list form-control" )
@@ -88,8 +101,8 @@ public partial class RadioListGeneric<TValue> : IModelEqualityComparer<TValue>
88101 . AddClassFromAttributes ( AdditionalAttributes )
89102 . Build ( ) ;
90103
91- private string ? GetButtonItemClassString ( SelectedItem item ) => CssBuilder . Default ( "btn" )
92- . AddClass ( $ "active bg-{ Color . ToDescriptionString ( ) } ", CurrentValueAsString == item . Value )
104+ private string ? GetButtonItemClassString ( SelectedItem < TValue > item ) => CssBuilder . Default ( "btn" )
105+ . AddClass ( $ "active bg-{ Color . ToDescriptionString ( ) } ", Equals ( Value , item . Value ) )
93106 . Build ( ) ;
94107
95108 /// <summary>
@@ -109,13 +122,14 @@ protected override void OnParametersSet()
109122 /// <summary>
110123 /// 点击选择框方法
111124 /// </summary>
112- private async Task OnClick ( SelectedItem < TValue > item )
125+ private async Task OnClick ( SelectedItem < TValue ? > item )
113126 {
114127 if ( ! IsDisabled )
115128 {
129+ CurrentValue = item . Value ;
116130 if ( OnSelectedChanged != null )
117131 {
118- await OnSelectedChanged ( Items , Value ) ;
132+ await OnSelectedChanged ( Value ) ;
119133 }
120134 StateHasChanged ( ) ;
121135 }
0 commit comments