Unplanned
Last Updated: 18 Dec 2019 07:18 by ADMIN
Edward
Created on: 17 Dec 2019 22:41
Category: UI for Blazor
Type: Feature Request
3
DropDrownTree component
As the subject says, this component is available in other libraries and is quite useful.  Would like to see it added to the Blazor suite of components.
1 comment
ADMIN
Marin Bratanov
Posted on: 18 Dec 2019 07:18

Hello Edward,

In the meantime you can implement this with the treeview and the animation container, something like this:

<input style="width: 250px;" class="k-textbox" @onfocus="@ShowContainer" @onblur="@HideContainer" />
@* you can also add filtering like here https://demos.telerik.com/blazor-ui/treeview/manual-filtering *@

<TelerikAnimationContainer @ref="myPopupRef" Width="250px" Height="300px" AnimationType="AnimationType.SlideDown" Class="k-popup">
    <TelerikTreeView Data="@FlatData">
        <TreeViewBindings>
            <TreeViewBinding IdField="Id" ParentIdField="ParentIdValue" ExpandedField="Expanded" TextField="Text" HasChildrenField="HasChildren" IconField="Icon" />
        </TreeViewBindings>
    </TelerikTreeView>
</TelerikAnimationContainer>

@code {
    Telerik.Blazor.Components.TelerikAnimationContainer myPopupRef;

    public void ShowContainer()
    {
        myPopupRef.ShowAsync();
    }

    public void HideContainer()
    {
        myPopupRef.HideAsync();
    }

    public class TreeItem
    {
        public int Id { get; set; }
        public string Text { get; set; }
        public int? ParentIdValue { get; set; }
        public bool HasChildren { get; set; }
        public string Icon { get; set; }
        public bool Expanded { get; set; }
    }

    public IEnumerable<TreeItem> FlatData { get; set; }

    protected override void OnInitialized()
    {
        LoadFlatData();
    }

    private void LoadFlatData()
    {
        List<TreeItem> items = new List<TreeItem>();

        items.Add(new TreeItem()
        {
            Id = 1,
            Text = "Project",
            ParentIdValue = null,
            HasChildren = true,
            Icon = "folder",
            Expanded = true
        });

        items.Add(new TreeItem()
        {
            Id = 2,
            Text = "Design",
            ParentIdValue = 1,
            HasChildren = true,
            Icon = "brush",
            Expanded = true
        });
        items.Add(new TreeItem()
        {
            Id = 3,
            Text = "Implementation",
            ParentIdValue = 1,
            HasChildren = true,
            Icon = "folder",
            Expanded = true
        });

        items.Add(new TreeItem()
        {
            Id = 4,
            Text = "site.psd",
            ParentIdValue = 2,
            HasChildren = false,
            Icon = "psd",
            Expanded = true
        });
        items.Add(new TreeItem()
        {
            Id = 5,
            Text = "index.js",
            ParentIdValue = 3,
            HasChildren = false,
            Icon = "js"
        });
        items.Add(new TreeItem()
        {
            Id = 6,
            Text = "index.html",
            ParentIdValue = 3,
            HasChildren = false,
            Icon = "html"
        });
        items.Add(new TreeItem()
        {
            Id = 7,
            Text = "styles.css",
            ParentIdValue = 3,
            HasChildren = false,
            Icon = "css"
        });

        FlatData = items;
    }
}

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor