diff --git a/src/BootstrapBlazor.Server/Components/Samples/Radios.razor b/src/BootstrapBlazor.Server/Components/Samples/Radios.razor index c2e2274260b..2aa4a75a258 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Radios.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/Radios.razor @@ -13,6 +13,12 @@ + + + + diff --git a/src/BootstrapBlazor.Server/Components/Samples/Radios.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Radios.razor.cs index c1d559449cb..5a75aea3600 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Radios.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Radios.razor.cs @@ -16,6 +16,9 @@ public sealed partial class Radios [NotNull] private IEnumerable? DemoValues { get; set; } + [NotNull] + private IEnumerable? AutoSelectValues { get; set; } + [NotNull] private IEnumerable? DisableValues { get; set; } @@ -70,6 +73,12 @@ protected override void OnInitialized() new("2", Localizer["RadiosItem2"]) }; + AutoSelectValues = new List(2) + { + new("1", Localizer["RadiosItem1"]), + new("2", Localizer["RadiosItem2"]) + }; + DisableValues = new List(2) { new("1", Localizer["RadiosItem1"]), @@ -177,6 +186,14 @@ private AttributeItem[] GetAttributes() => Type = "IEnumerable", ValueList = " — ", DefaultValue = "—" + }, + new() + { + Name = "AutoSelectFirstWhenValueIsNull", + Description = Localizer["RadiosAutoSelectFirstWhenValueIsNull"], + Type = "bool", + ValueList = "true|false", + DefaultValue = "true" } ]; diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json index d757b397cf0..8e433e80ae7 100644 --- a/src/BootstrapBlazor.Server/Locales/en-US.json +++ b/src/BootstrapBlazor.Server/Locales/en-US.json @@ -3056,7 +3056,10 @@ "RadiosAdd1": "Beijing", "RadiosAdd2": "Shanghai", "RadioListGenericTitle": "Generic List", - "RadioListGenericIntro": "Enable generic support by using the RadioListGeneric component with SelectedItem<TValue>" + "RadioListGenericIntro": "Enable generic support by using the RadioListGeneric component with SelectedItem<TValue>", + "RadiosAutoSelectFirstWhenValueIsNullTitle": "AutoSelectFirst", + "RadiosAutoSelectFirstWhenValueIsNullIntro": "The selection of RadioList candidates can be controlled by setting the AutoSelectFirstWhenValueIsNull parameter. The default value of the parameter is true, which means that if the current value of the component is inconsistent with the value in the candidate, the first candidate is automatically selected. If it is set to false, all candidates will be unselected.", + "RadiosAutoSelectFirstWhenValueIsNull": "Whether to select the first candidate by default when the value is not null" }, "BootstrapBlazor.Server.Components.Samples.Rates": { "RatesTitle": "Rate", diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json index 86baa5f54b6..03b07acd1cc 100644 --- a/src/BootstrapBlazor.Server/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json @@ -3056,7 +3056,10 @@ "RadiosAdd1": "北京", "RadiosAdd2": "上海", "RadioListGenericTitle": "泛型支持", - "RadioListGenericIntro": "通过使用 RadioListGeneric 组件配合 SelectedItem<TValue> 开启泛型支持" + "RadioListGenericIntro": "通过使用 RadioListGeneric 组件配合 SelectedItem<TValue> 开启泛型支持", + "RadiosAutoSelectFirstWhenValueIsNullTitle": "自动选择第一候选项", + "RadiosAutoSelectFirstWhenValueIsNullIntro": "通过设置 AutoSelectFirstWhenValueIsNull 参数控制 RadioList 候选项选中情况,参数默认值为 true,即如果组件当前值与候选项中值无一致值时,自动选中第一个候选项,设置为 false 后,候选项将全部为未选中状态。", + "RadiosAutoSelectFirstWhenValueIsNull": "值未 null 时是否默认选中第一个候选项" }, "BootstrapBlazor.Server.Components.Samples.Rates": { "RatesTitle": "Rate 评分",