File tree Expand file tree Collapse file tree 5 files changed +19
-3
lines changed
BootstrapBlazor/Components/Select Expand file tree Collapse file tree 5 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 240240 <div class =" col-12 col-sm-6 align-self-end" >
241241 <div class =" form-control" >@SelectedEnumItem </div >
242242 </div >
243+ <div class =" col-12 col-sm-6" >
244+ <Select @bind-Value =" _enumValueDemo" Items =" _enumValueDemoItems" ShowLabel =" true" DisplayText =" @Localizer[" SelectsEnumSelectText3 " ]" >
245+ </Select >
246+ </div >
247+ <div class =" col-12 col-sm-6 align-self-end" >
248+ <div class =" form-control" >@_enumValueDemo </div >
249+ </div >
243250 </div >
244251</DemoBlock >
245252
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ public sealed partial class Selects
5151
5252 private string ? _fooName ;
5353
54+ private List < SelectedItem > _enumValueDemoItems = [
55+ new ( "0" , "Primary" ) ,
56+ new ( "1" , "Middle" )
57+ ] ;
58+
59+ private EnumEducation _enumValueDemo = EnumEducation . Primary ;
60+
5461 /// <summary>
5562 /// <inheritdoc/>
5663 /// </summary>
@@ -69,7 +76,7 @@ private async Task<QueryData<SelectedItem>> OnQueryAsync(VirtualizeQueryOption o
6976 var items = Foos ;
7077 if ( ! string . IsNullOrEmpty ( option . SearchText ) )
7178 {
72- items = Foos . Where ( i => i . Name ! . Contains ( option . SearchText , StringComparison . OrdinalIgnoreCase ) ) . ToList ( ) ;
79+ items = [ .. Foos . Where ( i => i . Name ! . Contains ( option . SearchText , StringComparison . OrdinalIgnoreCase ) ) ] ;
7380 }
7481 return new QueryData < SelectedItem >
7582 {
Original file line number Diff line number Diff line change 31463146 "SelectsEnumDescription2": "Setting <code>PalceHolder</code> is not valid when the binding value is an enumerated type",
31473147 "SelectsEnumSelectText1": "Can be empty",
31483148 "SelectsEnumSelectText2": "Not empty",
3149+ "SelectsEnumSelectText3": "Using enum integer values as Items",
31493150 "SelectsNullableTitle": "The binding can be an empty type",
31503151 "SelectsNullableIntro": "<code>an example of the Select</code> component binding <code>int?</code> type",
31513152 "SelectsNullableDescription": "When the first option is selected, the binding value <code>SelectIntItem</code> to <code>null</code>",
Original file line number Diff line number Diff line change 31463146 "SelectsEnumDescription2" : " 绑定值为枚举类型时,设置 <code>PalceHolder</code> 无效" ,
31473147 "SelectsEnumSelectText1" : " 可为空" ,
31483148 "SelectsEnumSelectText2" : " 不为空" ,
3149+ "SelectsEnumSelectText3" : " 使用枚举整形值作为集合" ,
31493150 "SelectsNullableTitle" : " 绑定可为空类型" ,
31503151 "SelectsNullableIntro" : " <code>Select</code> 组件绑定 <code>int?</code> 类型示例" ,
31513152 "SelectsNullableDescription" : " 选中第一个选项时,绑定值 <code>SelectedIntItem</code> 为 <code>null</code>" ,
Original file line number Diff line number Diff line change @@ -294,7 +294,7 @@ private SelectedItem? SelectedRow
294294
295295 private SelectedItem ? GetSelectedRow ( )
296296 {
297- var item = GetItemWidthEnumValue ( )
297+ var item = GetItemWithEnumValue ( )
298298 ?? Rows . Find ( i => i . Value == CurrentValueAsString )
299299 ?? Rows . Find ( i => i . Active )
300300 ?? Rows . FirstOrDefault ( i => ! i . IsDisabled )
@@ -315,7 +315,7 @@ private SelectedItem? SelectedRow
315315 return item ;
316316 }
317317
318- private SelectedItem ? GetItemWidthEnumValue ( ) => ValueType . IsEnum
318+ private SelectedItem ? GetItemWithEnumValue ( ) => ValueType . IsEnum
319319 ? Rows . Find ( i => i . Value == Convert . ToInt32 ( Value ) . ToString ( ) )
320320 : null ;
321321
You can’t perform that action at this time.
0 commit comments