This is a migrated thread and some comments may be shown as answers.

add nodes dynamically with nodetemplates

1 Answer 44 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
chp
Top achievements
Rank 1
chp asked on 13 Jul 2011, 02:41 PM
hi i got problem, adding new nodes dynamically.
the nodetemplates are assigned by the templateneeded event:

protected void tree_TemplateNeeded(object sender, RadTreeNodeEventArgs e)
{
 
    ANDNode x=new ANDNode();
 
    e.Node.NodeTemplate = x;
 
}


my root node is a dropdownlist and when i change the selected index of the ddl, new child nodes should be added to the node.
My problem is, that the selectedchangedindex event will be not performed. Do you have an idea, why it will be not performed?

public class ANDNode : ITemplate
{
 
    public ANDNode()
    {
 
 
    }
    public void InstantiateIn(System.Web.UI.Control container)
    {
        DropDownList ddl = new DropDownList();
 
        ddl.AutoPostBack = true;
 
        ddl.ID = "ddl"+Guid.NewGuid().ToString();
        ddl.DataBinding+=new EventHandler(ddl_DataBinding);
        ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
         
        
        container.Controls.Add(ddl);
    }
 
    void  ddl_DataBinding(object sender, EventArgs e)
    {
        Global.FillExpressionItems((DropDownList)sender);
    }
 
 
    void ddl_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList ddl = (DropDownList)sender;
 
        RadTreeNode node = (RadTreeNode)ddl.NamingContainer;
        node.ExpandMode = TreeNodeExpandMode.ServerSide;
        node.Expanded = true;
 
        RadTreeNode child = new RadTreeNode();
        child.NodeTemplate = new ANDNode();
        node.Nodes.Add(child);
    }
 
}

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 15 Jul 2011, 04:18 PM
Hello Chp,

It is a little difficult for us to see what is causing the problem, would you please isolate it in a sample project so we can be more helpful.

Greetings,
Plamen Zdravkov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
TreeView
Asked by
chp
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or