-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.razor
91 lines (79 loc) · 2.53 KB
/
Index.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@page "/"
<h1>Hello, world!</h1>
Welcome to your new app.
@{
if (Breadcrumbs.Count != 0)
{
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
@for (int i = Breadcrumbs.Count - 1; i >= 0; i--)
{
var currentNodeInfo = Breadcrumbs[i];
<li class="breadcrumb-item active ">
@if (i != 0)
{
<a @onclick="@(() => SelectNode(currentNodeInfo.Text))" href="#">
@currentNodeInfo.Text
</a>
}
else
{
@currentNodeInfo.Text
}
</li>
}
</ol>
</nav>
}
}
<DxTreeView @ref="@TreeView" AllowSelectNodes="true"
SelectionChanged="@SelectionChanged">
<Nodes>
<DxTreeViewNode Text="Metals">
<Nodes>
<DxTreeViewNode Text="Alkali metals" />
<DxTreeViewNode Text="Alkaline earth metals" />
<DxTreeViewNode Text="Inner transition elements">
<Nodes>
<DxTreeViewNode Text="Lanthanides" />
<DxTreeViewNode Text="Actinides" />
</Nodes>
</DxTreeViewNode>
<DxTreeViewNode Text="Transition elements" />
<DxTreeViewNode Text="Other metals" />
</Nodes>
</DxTreeViewNode>
<DxTreeViewNode Text="Metalloids" />
<DxTreeViewNode Text="Nonmetals">
<Nodes>
<DxTreeViewNode Text="Halogens" />
<DxTreeViewNode Text="Noble gases" />
<DxTreeViewNode Text="Other nonmetals" />
</Nodes>
</DxTreeViewNode>
</Nodes>
</DxTreeView>
@code {
DxTreeView TreeView;
List<ITreeViewNodeInfo> Breadcrumbs;
protected override Task OnInitializedAsync()
{
Breadcrumbs = new List<ITreeViewNodeInfo>();
return base.OnInitializedAsync();
}
void SelectNode(string text) {
TreeView.SelectNode((n) => n.Text == text);
}
protected void SelectionChanged(TreeViewNodeEventArgs e)
{
var currentNodeInfo = e.NodeInfo;
Breadcrumbs.Clear();
do
{
Breadcrumbs.Add(currentNodeInfo);
currentNodeInfo = currentNodeInfo.Parent;
}
while (currentNodeInfo != null);
InvokeAsync(StateHasChanged);
}
}