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

Add node at zero index in RadComboBoxTree

1 Answer 67 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Vishram
Top achievements
Rank 1
Vishram asked on 12 May 2014, 10:19 AM
Hi, I tried to add a node at zero index with code :
   protected void fillComboTree(ref  Telerik.Web.UI.RadDropDownTree  cboTree)
    {
                            RadTreeNode radNodeTree= new RadTreeNode();
                            radNodeTree.Value = "S";
                            radNodeTree.Attributes.Add("isHeader","1");
                            radNodeTree.CssClass = "headerStyle";
                            radNodeTree.Text = ResourceHandler.GetValue("CompanyDataSite", m_sCulture);
                            radNodeTree.Font.Size = FontUnit.Small;
                            cboTree.Entries.Add(0,radNodeTree);
  } 

 Please tell me, how to add this object(radNodeTree) to Zero th positon in RadComboBoxTree.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 14 May 2014, 12:21 PM
Hello,

In order to add a new RadDropDownTree node, you may use the RadDropDownTree.EmbeddedTree property, which gives you access to the control's tree.

Once you have access to the tree, you can create RadTreeNodes and add them to the RadDropDownTree:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadDropDownTree1.EmbeddedTree.Nodes.Add(new RadTreeNode() { Text = "foo", Value = "A" });
    }
}

If you would like to create the RadTreeNode in a separate method and add it to the RadDropDownTree, you may follow the same logic:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadDropDownTree1.EmbeddedTree.Nodes.Add(fillRadDropDownTree());
    }
}
 
protected RadTreeNode fillRadDropDownTree()
{
    RadTreeNode radNodeTree = new RadTreeNode();
    radNodeTree.Value = "S";
    radNodeTree.Attributes.Add("isHeader", "1");
    radNodeTree.CssClass = "headerStyle";
    radNodeTree.Text = "Test";
    radNodeTree.Font.Size = FontUnit.Small;
 
    return radNodeTree;
}

You may refer to the Working with Nodes in Server-Side Code RadTreeView help article and the RadDropDownTree Data Binding help articles for additional information and examples in code.

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
DropDownTree
Asked by
Vishram
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or