how to limit branch from list

Hello, please help if possible
how to so that after fifth child parent relationship six child can't be added




3 Replies

KR Keerthana Rajendran Syncfusion Team December 23, 2021 06:18 AM UTC

Hi Aleqsandre,   
  
Greetings from Syncfusion support.  
   
Please clarify whether you need to limit the child nodes with Syncfusion Blazor TreeView or prevent the addition/drag of nodes to a parent node after fifth child. Based on that, we can proceed further.  
   
Meanwhile, have a glance on the below links to know about the available functionalities with Blazor TreeView component.   
   
   
   
Regards,   
  
Keerthana R.   



AL Aleqsandre December 23, 2021 07:09 AM UTC

Hello,

thank you for reply

I would like not to be able to insert 6 th child in the tree view datasource or in the list below


        public class MailItem

        {

            public string Id { get; set; }

            public string ParentId { get; set; }

            public string FolderName { get; set; }

            public bool Expanded { get; set; }

            public bool HasSubFolders { get; set; }

        }

        List<MailItem> MyFolder = new List<MailItem>();

        protected override void OnInitialized()

        {

            base.OnInitialized();

            MyFolder.Add(new MailItem

            {

                Id = "1",

                FolderName = "Inbox",

                HasSubFolders = true,

                Expanded = true

            });

            MyFolder.Add(new MailItem

            {

                Id = "3",

                ParentId = "1",

                FolderName = "Categories",

                Expanded = true,

                HasSubFolders = true

            });

            MyFolder.Add(new MailItem

            {

                Id = "7",

                ParentId = "3",

                FolderName = "Primary"

            });

            MyFolder.Add(new MailItem

            {

                Id = "14",

                ParentId = "7",

                FolderName = "Social"

            });

            MyFolder.Add(new MailItem

            {

                Id = "25",

                ParentId = "14",

                FolderName = "Promotions"

            });


            //I want not to be able to add 6th child to list

            MyFolder.Add(new MailItem

            {

                Id = "34",

                ParentId = "25",

                FolderName = "Promotions"

            });

        }



IL Indhumathy Loganathan Syncfusion Team December 27, 2021 01:33 PM UTC

Hi Aleqsandre, 
 
From the shared details, we understood that you wanted to render limited number of nested child nodes for TreeView. You wanted to remove the 6th level of nested child nodes from the TreeView. In TreeView component, we have e-level class for all the nodes. For your reference, we have prepared a sample where we removed the 6th level of nested child nodes using interop in Created event.  
 
Check the below code snippet. 
 
[index.razor] 
    public async void Created() 
    { 
        await jsRuntime.InvokeAsync<object>("removeChild"); 
    } 
[_Host.cshtml] 
    <script> 
        function removeChild() {   
            document.querySelectorAll('.e-level-6').forEach((item) => { 
                var element = item.closest('.e-level-5'); 
                if (element != null) 
                { 
                    element.getElementsByClassName('e-icons')[0].remove(); 
                    item.closest('.e-ul').remove(); 
                } 
            }); 
        } 
    </script> 
 
You can find the sample from the below link. 
 
 
Please check the sample and let us know if you need any further assistance. 
 
Regards, 
Indhumathy L 


Loader.
Up arrow icon