Hiding checkboxes based on logic

Right now i'm hiding all the parent checkbox nodes by using css which gives me the result below.  This works but i'm wondering is there a way to use specific logic that can only show the checkboxes based on my name "Chris" instead of another persons name below..  

  .CustomTree .e-list-item.e-level-1 .e-text-content.e-icon-wrapper
        .e-checkbox-wrapper {
            display: none
        }


1 Reply 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team October 19, 2020 07:46 AM UTC

Hi chris johansson, 
 
Greetings from Syncfusion support. 
 
We have checked your requirement with TreeView component. To achieve this, you need to set HtmlAttributes fields property and set the class name for each node in TreeView component. Then you can customize the checkbox of the required node based on this class name 
 
Refer to the below code snippet. 
 
@using Syncfusion.Blazor.Navigations 
<SfTreeView TValue="MailItem" CssClass="CustomTree" ShowCheckBox="true"> 
    <TreeViewFieldsSettings TValue="MailItem" Id="Id" DataSource="@MyFolder" Text="FolderName" HtmlAttributes="htmlAttributes" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="Expanded"></TreeViewFieldsSettings> 
</SfTreeView> 
 
@code{ 
    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; } 
        public Dictionary<string, object> htmlAttributes { 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, 
            htmlAttributes = new Dictionary<string, object> { { "class""hide"} } 
        }); 
        MyFolder.Add(new MailItem 
        { 
            Id = "2", 
            ParentId = "1", 
            HasSubFolders = true, 
            FolderName = "Categories", 
            Expanded=true,  
            htmlAttributes = new Dictionary<string, object> { { "class", "hide" } } 
        }); 
        MyFolder.Add(new MailItem 
        { 
            Id = "3", 
            ParentId = "2", 
 
            FolderName = "Primary" 
        }); 
} 
<style> 
    .CustomTree .e-list-item.hide > .e-text-content .e-checkbox-wrapper { 
        display: none 
    } 
</style> 
 
Refer to the sample link below. 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 


Marked as answer
Loader.
Up arrow icon