[CLOSED] Dynamically adding a node does not work

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [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?

    @(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]
  2. #2
    Hello!

    Try the following:

    .Root(
    	X.Node()
    	 .Text("Composers")
    	 .Expanded(true)
    	 .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)
    	)
    	.Children(c => {
    		if (true)
    		{
    			c.Add(new Node()
    			{
    				NodeID = "SwitchUser",
    				Text = "Switch User",
    				Icon = Icon.Group,
    				Leaf = true
    			});
    		}
    	})
    )
  3. #3
    Thank you,
    you can mark this as closed.

Similar Threads

  1. [CLOSED] Raw property is null when adding a node
    By RCN in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 22, 2012, 9:50 PM
  2. [CLOSED] Adding additional markup to selected TreePanel node
    By mbb in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 22, 2011, 3:06 PM
  3. [CLOSED] Adding node dynamicaly to treegrid on client side
    By bakardi in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Oct 22, 2011, 6:38 AM
  4. Replies: 4
    Last Post: Dec 27, 2010, 10:48 AM
  5. [CLOSED] Problem when adding a Tree Node from Javascript
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 15, 2010, 9:45 AM

Tags for this Thread

Posting Permissions