@using Astrol.Component.FileExplorer.Tree
@using Astrol.Entities.Basic.Static.Notification
@using Astrol.JSInterop.Base
@inject AstrolJSInterop jsI
<AstrolTree TItem="TreeItem" DataList="items" PropertyShow="@nameof(TreeItem.Text)" PropertyIcon="@nameof(TreeItem.Icon)" PropertyExpansed="@nameof(TreeItem.DefaultExpanse)" PropertyChildrenList="@nameof(TreeItem.Children)" OnClick="SelectItem" />
@code {
private async Task SelectItem(TreeItem item) {
await jsI.Notification($"The item has been selected: {item.Text}.".NotificationSucces());
}
private List<TreeItem> items = new List<TreeItem> {
new TreeItem() {
Text = "Project",
Icon = "astrol-folder-empty",
DefaultExpanse = true,
Children = new List<TreeItem> {
new TreeItem() {
Text = "Design",
Icon = "astrol-folder-empty",
DefaultExpanse = true,
Children = new List<TreeItem> {
new TreeItem() {
Text = "Photos",
Icon = "astrol-folder-empty",
Children = new List<TreeItem> {
new TreeItem()
{
Text = "logo.jpg",
Icon = "astrol-file-image"
},
new TreeItem()
{
Text = "front page.png",
Icon = "astrol-file-image"
},
},
},
new TreeItem() {
Text = "site.psd",
Icon = "astrol-doc"
},
},
},
new TreeItem() {
Text = "Implementation",
Icon = "astrol-folder-empty",
DefaultExpanse = true,
Children = new List<TreeItem> {
new TreeItem()
{
Text = "script.js",
Icon = "astrol-file-code"
},
new TreeItem() {
Text = "index.html",
Icon = "astrol-file-code"
},
new TreeItem() {
Text = "styles.css",
Icon = "astrol-file-code"
},
},
},
},
},
};
public class TreeItem {
public string Text { get; set; }
public List<TreeItem> Children { get; set; }
public string Icon { get; set; }
public bool DefaultExpanse { get; set; }
}
}