@@ -71,4 +72,72 @@
+
+
+ @((MarkupString)Localizer["IsVirtualizeDescription"].Value)
+
+
+
+ 1. 使用 OnQueryAsync 作为数据源
+
+
+
+
+
+
+
)
+
+
+
@context.Name
+
@Foo.GetTitle(context.Id)
+
+
+
+
+
+ @if (Model4 != null)
+ {
+
+ }
+
+
+
+
+ 2. 使用 Items 作为数据源
+
+
+
+
+
+
+
)
+
+
+
@context.Name
+
@Foo.GetTitle(context.Id)
+
+
+
+
+
+ @if (Model4 != null)
+ {
+
+ }
+
+
+
+
+
diff --git a/src/BootstrapBlazor.Server/Components/Samples/AutoFills.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/AutoFills.razor.cs
index 2803d12ea49..f75b92cc280 100644
--- a/src/BootstrapBlazor.Server/Components/Samples/AutoFills.razor.cs
+++ b/src/BootstrapBlazor.Server/Components/Samples/AutoFills.razor.cs
@@ -15,9 +15,13 @@ partial class AutoFills
[NotNull]
private Foo Model2 { get; set; } = new();
+
[NotNull]
private Foo Model3 { get; set; } = new();
+ [NotNull]
+ private Foo Model4 { get; set; } = new();
+
private static string? OnGetDisplayText(Foo? foo) => foo?.Name;
[NotNull]
@@ -29,10 +33,15 @@ partial class AutoFills
[NotNull]
private IEnumerable
? Items3 { get; set; }
+ [NotNull]
+ private IEnumerable? Items4 { get; set; }
+
[Inject]
[NotNull]
private IStringLocalizer? LocalizerFoo { get; set; }
+ private bool _isClearable = true;
+
///
protected override void OnInitialized()
{
@@ -46,6 +55,9 @@ protected override void OnInitialized()
Items3 = Foo.GenerateFoo(LocalizerFoo);
Model3 = Items3.First();
+
+ Items4 = Foo.GenerateFoo(LocalizerFoo);
+ Model4 = Items3.First();
}
private Task> OnCustomFilter(string searchText)
@@ -54,6 +66,27 @@ private Task> OnCustomFilter(string searchText)
return Task.FromResult(items);
}
+ private Task> OnCustomVirtulizeFilter(string searchText)
+ {
+ var items = string.IsNullOrEmpty(searchText) ? Items4 : Items4.Where(i => i.Name!.Contains(searchText));
+ return Task.FromResult(items);
+ }
+
+ private async Task> OnQueryAsync(VirtualizeQueryOption option)
+ {
+ await Task.Delay(200);
+ var items = Foo.GenerateFoo(LocalizerFoo);
+ if (!string.IsNullOrEmpty(option.SearchText))
+ {
+ items = [.. items.Where(i => i.Name!.Contains(option.SearchText, StringComparison.OrdinalIgnoreCase))];
+ }
+ return new QueryData
+ {
+ Items = items.Skip(option.StartIndex).Take(option.Count),
+ TotalCount = items.Count
+ };
+ }
+
///
/// Get property method
///
@@ -163,6 +196,14 @@ private AttributeItem[] GetAttributes() =>
Type = "bool",
ValueList = "true/false",
DefaultValue = "false"
+ },
+ new()
+ {
+ Name = nameof(AutoFill.IsVirtualize),
+ Description = Localizer["AttrIsVirtualize"],
+ Type = "bool",
+ ValueList = "true/false",
+ DefaultValue = "false"
}
];
}
diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json
index 04fa69ff71f..b4222f97bd4 100644
--- a/src/BootstrapBlazor.Server/Locales/en-US.json
+++ b/src/BootstrapBlazor.Server/Locales/en-US.json
@@ -2151,7 +2151,11 @@
"Att10": "Whether to expand the dropdown candidate menu when it gains focus",
"Att11": "Candidate template",
"Att12": "Whether to skip Enter key handling",
- "Att13": "Whether to skip Esc key processing"
+ "Att13": "Whether to skip Esc key processing",
+ "IsVirtualizeTitle": "Virtualize",
+ "IsVirtualizeIntro": "Set IsVirtualize to true enable virtual scroll for large data",
+ "IsVirtualizeDescription": "Component virtual scrolling supports two ways of providing data through Items or OnQueryAsync callback methods",
+ "AttrIsVirtualize": "Wether to enable virtualize"
},
"BootstrapBlazor.Server.Components.Samples.AutoCompletes": {
"Title": "AutoComplete",
@@ -3026,7 +3030,8 @@
"MultiSelectVirtualizeTitle": "Virtualize",
"MultiSelectVirtualizeIntro": "Set IsVirtualize to true enable virtual scroll for large data",
"MultiSelectVirtualizeDescription": "Component virtual scrolling supports two ways of providing data through Items or OnQueryAsync callback methods",
- "MultiSelectsAttribute_ShowSearch": "Whether to display the search box"
+ "MultiSelectsAttribute_ShowSearch": "Whether to display the search box",
+ "MultiSelectsAttribute_IsVirtualize": "Wether to enable virtualize"
},
"BootstrapBlazor.Server.Components.Samples.Radios": {
"RadiosTitle": "Radio",
diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json
index f457e614eb6..38185aa07b4 100644
--- a/src/BootstrapBlazor.Server/Locales/zh-CN.json
+++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json
@@ -2151,7 +2151,11 @@
"Att10": "获得焦点时是否展开下拉候选菜单",
"Att11": "候选项模板",
"Att12": "是否跳过 Enter 按键处理",
- "Att13": "是否跳过 Esc 按键处理"
+ "Att13": "是否跳过 Esc 按键处理",
+ "IsVirtualizeTitle": "虚拟滚动",
+ "IsVirtualizeIntro": "通过设置 IsVirtualize 参数开启组件虚拟功能特性",
+ "IsVirtualizeDescription": "组件虚拟滚动支持两种形式通过 Items 或者 OnQueryAsync 回调方法提供数据",
+ "AttrIsVirtualize": "是否开启虚拟滚动"
},
"BootstrapBlazor.Server.Components.Samples.AutoCompletes": {
"Title": "AutoComplete 自动完成",
@@ -3026,7 +3030,8 @@
"MultiSelectVirtualizeTitle": "虚拟滚动",
"MultiSelectVirtualizeIntro": "通过设置 IsVirtualize 参数开启组件虚拟功能特性",
"MultiSelectVirtualizeDescription": "组件虚拟滚动支持两种形式通过 Items 或者 OnQueryAsync 回调方法提供数据",
- "MultiSelectsAttribute_ShowSearch": "是否显示搜索框"
+ "MultiSelectsAttribute_ShowSearch": "是否显示搜索框",
+ "MultiSelectsAttribute_IsVirtualize": "是否开启虚拟滚动"
},
"BootstrapBlazor.Server.Components.Samples.Radios": {
"RadiosTitle": "Radio 单选框",
diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj
index 0ea624384ea..cbd8853a581 100644
--- a/src/BootstrapBlazor/BootstrapBlazor.csproj
+++ b/src/BootstrapBlazor/BootstrapBlazor.csproj
@@ -1,7 +1,7 @@
- 9.5.0-beta05
+ 9.5.0-beta07
diff --git a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.scss b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.scss
index d3841ca69d3..2c037528fcd 100644
--- a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.scss
+++ b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.scss
@@ -1,10 +1,5 @@
.auto-complete {
--bb-ac-padding-right: #{$bb-ac-padding-right};
- --bb-ac-menu-top: #{$bb-ac-menu-top};
- --bb-ac-menu-left: #{$bb-ac-menu-left};
- --bb-ac-menu-right: #{$bb-ac-menu-right};
- --bb-ac-menu-shadow: #{$bb-ac-menu-shadow};
- --bb-ac-dropdown-max-height: var(--bb-dropdown-max-height);
--bb-select-append-width: #{$bb-select-append-width};
--bb-select-append-color: #{$bb-select-append-color};
position: relative;
@@ -15,11 +10,7 @@
}
.dropdown-menu {
- top: var(--bb-ac-menu-top);
- left: var(--bb-ac-menu-left);
- right: var(--bb-ac-menu-right);
- box-shadow: var(--bb-ac-menu-shadow);
- max-height: var(--bb-ac-dropdown-max-height);
+ width: 100%;
}
.ac-loading {
diff --git a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor
index f500090e190..d7200fcd4dd 100644
--- a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor
+++ b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor
@@ -1,4 +1,5 @@
@namespace BootstrapBlazor.Components
+@using Microsoft.AspNetCore.Components.Web.Virtualization
@typeparam TValue
@inherits PopoverCompleteBase
@@ -17,23 +18,58 @@
placeholder="@PlaceHolder" disabled="@Disabled" @ref="FocusElement" />
+ @if (GetClearable())
+ {
+
+ }