May 24, 2013, 5:18 PM
[CLOSED] Dynamically adding a node does not work
Hi,
I create a TreePanel like you can see in the code below, then right after that, I try to add a node dynamically.
However, it doesn't work.
Am I doing anything wrong?
I create a TreePanel like you can see in the code below, then right after that, I try to add a node dynamically.
However, it doesn't work.
Am I doing anything wrong?
@(Html.X().Viewport()
.Layout(LayoutType.Border)
.Items(items =>
{
items.Add(Html.X().TreePanel()
.ID("MainMenu")
.Title("Main Menu")
.RootVisible(false)
.Root(Html.X().Node()
.NodeID("Root")
.Text("Root")
.Children(Html.X().Node()
.NodeID("MyTasks")
.Text("My Tasks")
.Icon(Icon.Application)
.Expandable(false),
Html.X().Node()
.NodeID("PendingTasks")
.Text("Pending Tasks")
.Icon(Icon.ApplicationGo)
.Expandable(false),
Html.X().Node()
.NodeID("ClosedTasks")
.Text("Closed Tasks")
.Icon(Icon.ApplicationStop)
.Expandable(false),
Html.X().Node()
.NodeID("Search")
.Text("Search")
.Icon(Icon.Magnifier)
.Expandable(false),
Html.X().Node()
.NodeID("OpenTasks")
.Text("Open Tasks")
.Icon(Icon.ApplicationCascade)
)
)
);
if (Model.IsSwitchUser)
{
Ext.Net.Node switchUserNode = new Ext.Net.Node();
switchUserNode.NodeID = "SwitchUser";
switchUserNode.Text = "Switch User";
switchUserNode.Leaf = true;
switchUserNode.Icon = Icon.Group;
X.GetCmp<TreePanel>("MainMenu").GetNodeById("Root").AppendChild(switchUserNode);
//also tried
//X.GetCmp<TreePanel>("MainMenu").GetRootNode().AppendChild(switchUserNode);
}
}
)
)
Last edited by Daniil; May 27, 2013 at 10:55 AM.
Reason: [CLOSED]