Skip to content

Commit 4e58224

Browse files
committed
doc: 更新示例
1 parent 9603422 commit 4e58224

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,21 @@
338338
<DemoBlock Title="@Localizer["SelectsClearableTitle"]"
339339
Introduction="@Localizer["SelectsClearableIntro"]"
340340
Name="IsClearable">
341+
<section ignore>
342+
<p>@((MarkupString)Localizer["SelectsClearableDesc"].Value)</p>
343+
</section>
341344
<div class="row g-3">
342345
<div class="col-12 col-sm-6">
343-
<Select Color="Color.Primary" IsClearable="true" Items="ClearableItems" Value="ClearableModel.Name"></Select>
346+
<Select IsClearable="true" Items="ClearableItems" Value="ClearableModel.NullableName" ShowLabel="true" DisplayText="string?"></Select>
347+
</div>
348+
<div class="col-12 col-sm-6">
349+
<Select IsClearable="true" Items="Items" Value="ClearableModel.Name" ShowLabel="true" DisplayText="string"></Select>
350+
</div>
351+
<div class="col-12 col-sm-6">
352+
<Select IsClearable="true" Items="IntItems" Value="ClearableModel.NullableCount" ShowLabel="true" DisplayText="int?"></Select>
344353
</div>
345354
<div class="col-12 col-sm-6">
346-
<Select Color="Color.Primary" IsClearable="true" Items="Items" Value="ClearableModel.Name"></Select>
355+
<Select IsClearable="true" Items="IntItems" Value="ClearableModel.Count" ShowLabel="true" DisplayText="int"></Select>
347356
</div>
348357
</div>
349358
</DemoBlock>

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,18 @@ private Task OnItemChanged(SelectedItem item)
101101

102102
private Foo BindingModel { get; set; } = new Foo();
103103

104-
private Foo ClearableModel { get; set; } = new Foo();
104+
private MockModel ClearableModel { get; set; } = new();
105+
106+
class MockModel
107+
{
108+
public string? NullableName { get; set; }
109+
110+
public string Name { get; set; } = "";
111+
112+
public int Count { get; set; } = 1;
113+
114+
public int? NullableCount { get; set; }
115+
}
105116

106117
private SelectedItem? Item { get; set; }
107118

@@ -230,6 +241,14 @@ private string GetSelectedBoolItemString()
230241
new("abcde", "abcde")
231242
];
232243

244+
private readonly SelectedItem[] IntItems =
245+
[
246+
new("1", "1"),
247+
new("12", "12"),
248+
new("123", "123"),
249+
new("1234", "1234")
250+
];
251+
233252
private static Task<bool> OnBeforeSelectedItemChange(SelectedItem item)
234253
{
235254
return Task.FromResult(true);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,6 +3111,7 @@
31113111
"SelectsBindingIntro": "The values in the text box change as you change the drop-down option by binding the <code>Model.Name</code> property to the component with <code>Select</code>",
31123112
"SelectsClearableTitle": "Clearable",
31133113
"SelectsClearableIntro": "You can clear Select using a clear icon",
3114+
"SelectsClearableDesc": "Cannot be a null integer. Setting <code>IsClearable</code> has no effect. Its default value is <b>0</b>",
31143115
"SelectsBindingSelectedItemTitle": "Select two-way binding SelectItem type",
31153116
"SelectsBindingSelectedItemIntro": "The values in the text box change as you change the drop-down option by binding the <code>SelectItem</code> property to the component with <code>Select</code> .",
31163117
"SelectsCascadingTitle": "Select cascading binding",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,6 +3111,7 @@
31113111
"SelectsBindingIntro": "通过 <code>Select</code> 组件绑定 <code>Model.Name</code> 属性,改变下拉框选项时,文本框内的数值随之改变。",
31123112
"SelectsClearableTitle": "可清空单选",
31133113
"SelectsClearableIntro": "包含清空按钮,可将选择器清空为初始状态",
3114+
"SelectsClearableDesc": "不可为空整形设置 <code>IsClearable</code> 无效,其默认值为 <b>0</b>",
31143115
"SelectsBindingSelectedItemTitle": "Select 双向绑定 SelectItem",
31153116
"SelectsBindingSelectedItemIntro": "通过 <code>Select</code> 组件绑定 <code>SelectItem</code> 属性,改变下拉框选项时,文本框内的数值随之改变。",
31163117
"SelectsCascadingTitle": "Select 级联绑定",

0 commit comments

Comments
 (0)