diff --git a/src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor b/src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor
index a174ff0b61a..8bd7c41b9e5 100644
--- a/src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor
+++ b/src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor
@@ -27,7 +27,7 @@
Introduction="@Localizer["TreeViewNormalIntro"]"
Name="Normal">
@((MarkupString)Localizer["TreeViewNormalDescription"].Value)
-
+
@@ -45,9 +45,10 @@
+
-
+
@@ -59,14 +60,14 @@
-
+
@((MarkupString)Localizer["TreeViewAccordionModelDescription"].Value)
-
+
@((MarkupString)Localizer["TreeViewDefaultExpandDescription"].Value)
-
+
@((MarkupString)Localizer["TreeViewTreeDisplayIconDescription"].Value)
-
+
@((MarkupString)Localizer["TreeViewTreeClickExpandDescription"].Value)
-
+
@((MarkupString)Localizer["TreeViewTreeValidationFormDescription"].Value)
-
+
@@ -111,44 +112,28 @@
@((MarkupString)Localizer["TreeViewTreeLazyLoadingDescription"].Value)
-
+
-
+
-
+
-
+
-
-
- @((MarkupString)Localizer["TreeViewCustomCheckedItemsTips1"].Value)
-
-
-
-
-
@@ -157,33 +142,33 @@
-
+
-
+
-
+
-
+
@((MarkupString)Localizer["TreeViewMaxSelectedCountDesc"].Value)
-
@@ -191,7 +176,7 @@
Introduction="@Localizer["TreeViewEnableKeyboardArrowUpDownIntro"]"
Name="EnableKeyboard">
-
@@ -202,22 +187,12 @@
@((MarkupString)Localizer["TreeViewVirtualizeDescription"].Value)
-
-@*
-
- @((MarkupString)Localizer["TreeViewFlatItemsDescription"].Value)
-
-
-
- *@
diff --git a/src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor.cs
index 55c11e8875d..54d7389596a 100644
--- a/src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor.cs
+++ b/src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor.cs
@@ -23,8 +23,11 @@ public sealed partial class TreeViews
private ConsoleLogger? Logger3 { get; set; }
private bool DisableCanExpand { get; set; }
+
private bool IsDisabled { get; set; }
+ private List> NormalItems { get; } = TreeFoo.GetTreeItems();
+
private List> Items { get; } = TreeFoo.GetTreeItems();
private bool AutoCheckChildren { get; set; }
@@ -33,15 +36,17 @@ public sealed partial class TreeViews
private List> DisabledItems { get; } = GetDisabledItems();
+ private List>? AccordionItems { get; } = TreeFoo.GetAccordionItems();
+
private List> ExpandItems { get; } = GetExpandItems();
private List> CheckedItems { get; set; } = GetCheckedItems();
- private static List> GetIconItems() => TreeFoo.GetTreeItems();
+ private static List> IconItems { get; set; } = TreeFoo.GetTreeItems();
- private List> GetClickExpandItems { get; } = TreeFoo.GetTreeItems();
+ private List> ClickExpandItems { get; } = TreeFoo.GetTreeItems();
- private List> GetFormItems { get; } = TreeFoo.GetTreeItems();
+ private List> FormItems { get; } = TreeFoo.GetTreeItems();
private List> CheckedItems2 { get; } = TreeFoo.GetTreeItems();
@@ -61,7 +66,11 @@ public sealed partial class TreeViews
private List> VirtualizeItems { get; } = TreeFoo.GetVirtualizeTreeItems();
- private List> FlatItems { get; } = TreeFoo.GetFlatItems();
+ private List> LazyItems { get; } = TreeFoo.GetLazyItems();
+
+ private List> ColorItems { get; } = TreeFoo.GetColorItems();
+
+ private List> TemplateItems { get; } = TreeFoo.GetTemplateItems();
private Foo Model => Foo.Generate(LocalizerFoo);
@@ -85,6 +94,11 @@ private void OnRefresh()
CheckedItems = GetCheckedItems();
}
+ private void OnClickAddNode()
+ {
+ CheckedItems.Add(new TreeViewItem(new TreeFoo() { Id = $"Id-{DateTime.Now.Ticks}" }) { Text = DateTime.Now.ToString() });
+ }
+
private static List> GetCheckedItems()
{
var ret = TreeFoo.GetTreeItems();
@@ -114,35 +128,13 @@ private static List> GetDisabledItems()
return ret;
}
- private static List> GetAccordionItems()
- {
- var ret = TreeFoo.GetTreeItems();
- ret[1].Items[0].HasChildren = true;
- return ret;
- }
-
private static async Task>> OnExpandNodeAsync(TreeViewItem node)
{
- await Task.Delay(800);
+ await Task.Delay(200);
var item = node.Value;
return new TreeViewItem[] { new(new TreeFoo() { Id = $"{item.Id}-101", ParentId = item.Id }) { Text = "懒加载子节点1", HasChildren = true }, new(new TreeFoo() { Id = $"{item.Id}-102", ParentId = item.Id }) { Text = "懒加载子节点2" } };
}
- private static async Task>> CustomCheckedNodeOnExpandNodeAsync(TreeViewItem node)
- {
- await Task.Delay(800);
- var item = node.Value;
- return TreeFoo.GetCheckedTreeItems(item.Id);
- }
-
- private static List> GetCustomCheckedItems()
- {
- var ret = TreeFoo.GetCheckedTreeItems();
- ret[0].IsExpand = true;
- ret[0].Items = TreeFoo.GetCheckedTreeItems();
- return ret;
- }
-
private static List> GetExpandItems()
{
var ret = TreeFoo.GetTreeItems();
@@ -155,31 +147,6 @@ private static Task OnFormTreeItemClick(TreeViewItem item)
return Task.CompletedTask;
}
- private static List> GetLazyItems()
- {
- var ret = TreeFoo.GetTreeItems();
- ret[1].Items[0].IsExpand = true;
- ret[2].Text = "懒加载延时";
- ret[2].HasChildren = true;
- return ret;
- }
-
- private static List> GetTemplateItems()
- {
- var ret = TreeFoo.GetTreeItems();
- ret[0].Template = foo => BootstrapDynamicComponent.CreateComponent(new Dictionary() { [nameof(CustomerTreeItem.Foo)] = foo }).Render();
- return ret;
- }
-
- private static List> GetColorItems()
- {
- var ret = TreeFoo.GetTreeItems();
- ret[0].CssClass = "text-primary";
- ret[1].CssClass = "text-success";
- ret[2].CssClass = "text-danger";
- return ret;
- }
-
private Task OnTreeItemChecked2(List> items)
{
Logger3.Log($"当前共选中{items.Count}项");
@@ -249,38 +216,6 @@ private static async Task>> OnExpandVirtualNod
return items;
}
- private class CustomerTreeItem : ComponentBase
- {
- [Inject]
- [NotNull]
- private ToastService? ToastService { get; set; }
-
- [Parameter]
- [NotNull]
- public TreeFoo? Foo { get; set; }
-
- ///
- /// BuildRenderTree
- ///
- ///
- protected override void BuildRenderTree(RenderTreeBuilder builder)
- {
- builder.OpenElement(3, "span");
- builder.AddAttribute(4, "class", "me-3");
- builder.AddContent(5, Foo.Text);
- builder.CloseElement();
-
- builder.OpenComponent