<style>
.CustomTree.e-treeview .e-list-item.e-level-1 > .e-text-content .e-checkbox-wrapper,
.CustomTree.e-treeview .e-list-item.e-level-2 > .e-text-content .e-checkbox-wrapper {
display: none
}
</style> |
@using Syncfusion.Blazor.Navigations
<SfTreeView TValue="Music" ShowCheckBox="true" CssClass="CustomTree" CheckedNodes="CheckedNodes" AutoCheck="false">
<TreeViewFieldsSettings TValue="Music" Id="Id" DataSource="@Countries" Text="Name" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" Selected="IsSelected"></TreeViewFieldsSettings>
<TreeViewEvents TValue="Music" NodeChecking="nodeChecking"></TreeViewEvents>
</SfTreeView>
@code{
public string[] CheckedNodes;
public void nodeChecking(NodeCheckEventArgs args)
{
if (args.IsInteracted && (args.Action == "check") && ((this.CheckedNodes == null) || (args.Data[0].Id != this.CheckedNodes[0])))
{
//prevent the check action of TreeVew node
args.Cancel = true;
// Check only the corresponding node of TreeView component.
CheckedNodes = new string[] { args.Data[0].Id };
}
}
} |
<style>
.e-treeview .e-list-item.e-has-child > .e-text-content .e-checkbox-wrapper {
display: none
}
</style> |
@using Syncfusion.Blazor.Navigations
<div class="control-section">
<div class="control_wrapper">
<SfTreeView TValue="StudyParameterGroupViewModel" ShowCheckBox="true" AutoCheck="false">
<TreeViewFieldsSettings DataSource="@TreeDataSource" Id="Id" Text="DisplayText" Expanded="Expanded" Selected="Selected" Child="@("Children")"></TreeViewFieldsSettings>
<TreeViewEvents TValue="StudyParameterGroupViewModel"></TreeViewEvents>
</SfTreeView>
</div>
</div>
@code{
List<StudyParameterGroupViewModel> TreeDataSource = new List<StudyParameterGroupViewModel>();
protected override void OnInitialized()
{
base.OnInitialized();
TreeDataSource.Add(new StudyParameterGroupViewModel
{
Id = 01,
DisplayText = "Local Disk (C:)",
Expanded = true,
Children = new List<StudyParameterGroupViewModel>()
{
new StudyParameterGroupViewModel { Id = 015, DisplayText = "Program Files",
Children = new List<StudyParameterGroupViewModel>()
{
new StudyParameterGroupViewModel { Id = 011, DisplayText = "Windows NT" },
new StudyParameterGroupViewModel { Id = 012, DisplayText = "Windows Mail" },
new StudyParameterGroupViewModel { Id = 012, DisplayText = "Windows Photo Viewer" }
},
},
},
});
}
class StudyParameterGroupViewModel
{
public int Id { get; set; }
public string DisplayText { get; set; }
public string Icon { get; set; }
public bool Expanded { get; set; }
public bool Selected { get; set; }
public List<StudyParameterGroupViewModel> Children { get; set; }
}
}
<style>
.e-treeview .e-list-item.e-has-child > .e-text-content .e-checkbox-wrapper {
display: none
}
</style> |