Radzen Tree Blazor

Hi, I'm trying to use the Radzen tree, but not success to show last nested value
Here's my code. Thank you :slight_smile:

       <RadzenTreeLevel TextProperty="DocumentName" ChildrenProperty="Children">
            <Template>
                <strong>@((context.Value as TreeNode).DocumentName)\</strong>
            </Template>
        </RadzenTreeLevel>
        <RadzenTreeLevel TextProperty="DocumentName" HasChildren="@((product) => true)" />
   </RadzenTree>
@code{
    This text will be hidden
    List<TreeNode> node = new List<TreeNode>();


    RenderFragment<RadzenTreeItem> FileOrFolderTemplate = (context) => builder =>
    {
        string path = context.Value as string;
        bool isDirectory = Directory.Exists(path);

        // Add a RadzenIcon to the template

        builder.OpenComponent<RadzenIcon>(0);
        builder.AddAttribute(1, "Icon", isDirectory ? "folder" : "insert_drive_file");

        // Set some margin if the current data item is a file (!isDirectory)

        if (!isDirectory)
        {
            builder.AddAttribute(2, "Style", "margin-left: 24px");
        }

        builder.CloseComponent();

        // Append the current item text
        builder.AddContent(3, context.Text);
    };


    void LoadFiles(TreeExpandEventArgs args)
    {
        var n = args.Value as TreeNode;
        var directory = args.Value as string;

        args.Children.Data = n.Children;
        args.Children.TextProperty = "DocumentName";
       args.Children.HasChildren = (path) => Directory.Exists(directory);

        // Propagate the Template to the children
        //args.Children.Template = FileOrFolderTemplate;
    }


    protected override void OnInitialized()
    {


        node.Add(new TreeNode
        {
            Id = 1,
            ParentId = 0,
            DocumentName = "First Folder",
            DocumentDescription = "blasss",
            Icon = "folder",
            IsFile = false,
            Children = new List<TreeNode>()
        {
                new TreeNode()
                {
                     Id = 3,
                    ParentId = 1,
                    DocumentName = "First Child",
                    DocumentDescription = "blassss323ss",
                    Icon= "folder",
                    IsFile = false,
                    Children = new List<TreeNode>()
                {
                        new TreeNode()
                        {
                             Id = 6,
                            ParentId = 3,
                            DocumentName = "First Child to child",
                            Icon ="folder",
                            IsFile = false,
                            DocumentDescription = "blassss2232323323ss",
                             Children = new List<TreeNode>()
                {
                        new TreeNode()
                        {
                             Id = 6,
                            ParentId = 3,
                            DocumentName = "File",
                            Icon ="insert_drive_file",
                            IsFile = true,
                            DocumentDescription = "blassss2232323323ss",

                        }
                    }
                        }
                    }
                }
            }
        });
        //node.Add(new TreeNode { Id = 3, ParentId = 1, DocumentName = "First Child", DocumentDescription = "blassss323ss" });


    }
}```

Hi @Rancov_Miroslav,

I am not sure what you are asking. It looks though that you have arbitrary nested tree structure. In this case the tree levels won't be very convenient. You can check the file system demo and the related section in the documentation.

Hi, I'm new to Blazor (c#). I'm js developer, and I don't understand how do I know in this case if the folder has children HasChildren="@((product) => true)" dynamically based on the list below.
Thank you!

        node.Add(new TreeNode
        {
            Id = 1,
            ParentId = 0,
            DocumentName = "First Folder",
            DocumentDescription = "blasss",
            Icon = "folder",
            IsFile = false,
            Children = new List<TreeNode>()
    {
                new TreeNode()
                {
                     Id = 3,
                    ParentId = 1,
                    DocumentName = "First Child",
                    DocumentDescription = "blassss323ss",
                    Icon= "folder",
                    IsFile = false,
                    Children = new List<TreeNode>()
            {
                        new TreeNode()
                        {
                             Id = 6,
                            ParentId = 3,
                            DocumentName = "First Child to child",
                            Icon ="folder",
                            IsFile = false,
                            DocumentDescription = "blassss2232323323ss",
                             Children = new List<TreeNode>()
            {
                        new TreeNode()
                        {
                             Id = 6,
                            ParentId = 3,
                            DocumentName = "File",
                            Icon ="insert_drive_file",
                            IsFile = true,
                            DocumentDescription = "blassss2232323323ss",

                        }
                    }
                        }
                    }
                }
            }
        });```