ant-design-blazor/components/tree-select/SimpleTreeSelect.cs
gmij 0abc1db548 feat(module: TreeSelect): add tree-select component 🚀 (#1773)
* fixed. Fix network error when requesting contributor list in local development environment

* fixed. Fix Chinese garbled code

* Update Dynamic.razor

* update. Adjust the base class of the select control to selectbase, and extract the common methods to prepare for tree select.

* fixed. Adjust the type of the parent control to selectbase

* tree-select完成基础编码工作。

* fix. 重新修订冲突解决时误删的变量

* fix. 修复在多选模式下无法显示初始值的bug

* fix some styles

* add. tree add Node UnSelect Event

* fix . Node Multiple Select Bug.

* fix Tree UnSelect invalid.

* fix. tree multiple select support.

* fix. select option sync tree node selected.

* fix. multiple select, old selected values has clear

* fix loop update exception

* 修复合并带来的冲突

* add. allow clear feat. but not finish.

* fix merge bug

* fix merge bug

* fix. supplementary notes

* update demo data with react demo

* add. 添加静态下拉树的能力,以及单选和多选的demo

* fix. 优化下拉显示树时,树选项的选中逻辑。

* fix demo

* fix. 静态下拉树时,出现错选的bug

* fix merge bugs.

* fix merge bugs.

* add. static dataObject Bind Support

* 将下拉树中,对偏平数据源的处理,移到simpleTreeSelect中

* fix ChildrenExpression
2021-09-08 19:00:05 +08:00

46 lines
1.5 KiB
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Components;
namespace AntDesign
{
public class SimpleTreeSelect<TItem> : TreeSelect<TItem> where TItem : class
{
protected IEnumerable<TItem> RootData => ChildrenMethodExpression?.Invoke(RootValue);
/// <summary>
/// Specifies a method to return a child node
/// </summary>
[Parameter]
public Func<string, IList<TItem>> ChildrenMethodExpression { get; set; }
protected override Func<TreeNode<TItem>, IList<TItem>> TreeNodeChildrenExpression => node => ChildrenMethodExpression(TreeNodeKeyExpression(node));
protected override Dictionary<string, object> TreeAttributes
{
get
{
return new()
{
{ "DataSource", RootData },
{ "TitleExpression", TreeNodeTitleExpression },
{ "DefaultExpandAll", TreeDefaultExpandAll },
{ "KeyExpression", TreeNodeKeyExpression },
{ "ChildrenExpression", TreeNodeChildrenExpression },
{ "DisabledExpression", TreeNodeDisabledExpression },
{ "IsLeafExpression", TreeNodeIsLeafExpression }
};
}
}
}
}