Add node at zero index in RadComboBoxTree

2 posts, 0 answers
  1. Vishram
    Vishram avatar
    3 posts
    Member since:
    May 2014

    Posted 12 May 2014 Link to this post

    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.

  2. Dimitar
    Admin
    Dimitar avatar
    281 posts

    Posted 14 May 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top