Skip to content

Commit 8f92817

Browse files
authored
doc(RadioList): add sample code for AutoSelectFirstWhenValueIsNull (#5367)
* doc: 更新 RadioList 示例 * doc: 更新资源文件
1 parent 6616a6f commit 8f92817

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/BootstrapBlazor.Server/Components/Samples/Radios.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
<ConsoleLogger @ref="Logger" />
1414
</DemoBlock>
1515

16+
<DemoBlock Title="@Localizer["RadiosAutoSelectFirstWhenValueIsNullTitle"]"
17+
Introduction="@Localizer["RadiosAutoSelectFirstWhenValueIsNullIntro"]"
18+
Name="AutoSelectFirstWhenValueIsNull">
19+
<RadioList TValue="string" Items="@AutoSelectValues" AutoSelectFirstWhenValueIsNull="false" />
20+
</DemoBlock>
21+
1622
<DemoBlock Title="@Localizer["RadiosDisableTitle"]"
1723
Introduction='@Localizer["RadiosDisableIntro"]'
1824
Name="Disable">

src/BootstrapBlazor.Server/Components/Samples/Radios.razor.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public sealed partial class Radios
1616
[NotNull]
1717
private IEnumerable<SelectedItem>? DemoValues { get; set; }
1818

19+
[NotNull]
20+
private IEnumerable<SelectedItem>? AutoSelectValues { get; set; }
21+
1922
[NotNull]
2023
private IEnumerable<SelectedItem>? DisableValues { get; set; }
2124

@@ -70,6 +73,12 @@ protected override void OnInitialized()
7073
new("2", Localizer["RadiosItem2"])
7174
};
7275

76+
AutoSelectValues = new List<SelectedItem>(2)
77+
{
78+
new("1", Localizer["RadiosItem1"]),
79+
new("2", Localizer["RadiosItem2"])
80+
};
81+
7382
DisableValues = new List<SelectedItem>(2)
7483
{
7584
new("1", Localizer["RadiosItem1"]),
@@ -177,6 +186,14 @@ private AttributeItem[] GetAttributes() =>
177186
Type = "IEnumerable<TItem>",
178187
ValueList = " — ",
179188
DefaultValue = "—"
189+
},
190+
new()
191+
{
192+
Name = "AutoSelectFirstWhenValueIsNull",
193+
Description = Localizer["RadiosAutoSelectFirstWhenValueIsNull"],
194+
Type = "bool",
195+
ValueList = "true|false",
196+
DefaultValue = "true"
180197
}
181198
];
182199

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3056,7 +3056,10 @@
30563056
"RadiosAdd1": "Beijing",
30573057
"RadiosAdd2": "Shanghai",
30583058
"RadioListGenericTitle": "Generic List",
3059-
"RadioListGenericIntro": "Enable generic support by using the <code>RadioListGeneric</code> component with <code>SelectedItem&lt;TValue&gt;</code>"
3059+
"RadioListGenericIntro": "Enable generic support by using the <code>RadioListGeneric</code> component with <code>SelectedItem&lt;TValue&gt;</code>",
3060+
"RadiosAutoSelectFirstWhenValueIsNullTitle": "AutoSelectFirst",
3061+
"RadiosAutoSelectFirstWhenValueIsNullIntro": "The selection of <code>RadioList</code> candidates can be controlled by setting the <code>AutoSelectFirstWhenValueIsNull</code> parameter. The default value of the parameter is <b>true</b>, 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 <b>false</b>, all candidates will be unselected.",
3062+
"RadiosAutoSelectFirstWhenValueIsNull": "Whether to select the first candidate by default when the value is not null"
30603063
},
30613064
"BootstrapBlazor.Server.Components.Samples.Rates": {
30623065
"RatesTitle": "Rate",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3056,7 +3056,10 @@
30563056
"RadiosAdd1": "北京",
30573057
"RadiosAdd2": "上海",
30583058
"RadioListGenericTitle": "泛型支持",
3059-
"RadioListGenericIntro": "通过使用 <code>RadioListGeneric</code> 组件配合 <code>SelectedItem&lt;TValue&gt;</code> 开启泛型支持"
3059+
"RadioListGenericIntro": "通过使用 <code>RadioListGeneric</code> 组件配合 <code>SelectedItem&lt;TValue&gt;</code> 开启泛型支持",
3060+
"RadiosAutoSelectFirstWhenValueIsNullTitle": "自动选择第一候选项",
3061+
"RadiosAutoSelectFirstWhenValueIsNullIntro": "通过设置 <code>AutoSelectFirstWhenValueIsNull</code> 参数控制 <code>RadioList</code> 候选项选中情况,参数默认值为 <b>true</b>,即如果组件当前值与候选项中值无一致值时,自动选中第一个候选项,设置为 <b>false</b> 后,候选项将全部为未选中状态。",
3062+
"RadiosAutoSelectFirstWhenValueIsNull": "值未 null 时是否默认选中第一个候选项"
30603063
},
30613064
"BootstrapBlazor.Server.Components.Samples.Rates": {
30623065
"RatesTitle": "Rate 评分",

0 commit comments

Comments
 (0)