|
@page "/"
@using Syncfusion.Blazor
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Navigations
<SfButton OnClick="onBtnClick">Add</SfButton>
<SfTreeView TValue="MusicAlbum" ShowCheckBox="true" AutoCheck="true" @ref="tree">
<TreeViewFieldsSettings TValue="MusicAlbum" Id="Id" DataSource="@Albums" Text="Caption" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" IsChecked="IsChecked"></TreeViewFieldsSettings>
</SfTreeView>
@code{
public class MusicAlbum
{
public int Id { get; set; }
public int? ParentId { get; set; }
public string Caption { get; set; }
public bool Expanded { get; set; }
public bool? IsChecked { get; set; }
public bool HasChild { get; set; }
}
SfTreeView<MusicAlbum> tree;
List<MusicAlbum> Albums = new List<MusicAlbum>();
protected override void OnInitialized()
{
base.OnInitialized();
}
void onBtnClick()
{
List<object> TreeData = new List<object>();
TreeData.Add(new
{
Id = 1,
Caption = "Australia",
HasChild = true,
});
for( var c = 0; c < 300; c++ )
{
TreeData.Add(new
{
Id = c,
Caption = c.ToString(),
ParentId = 1,
});
}
this.tree.AddNodes(TreeData, 1, null, false);
}
} |
|
|
|
Description |
Link |
|
Getting started |
|
|
Data binding |
|
|
Add node using context menu |
|
|
API reference |