Generate radtreeview dynamically

8 posts, 0 answers
  1. Senthil ramna
    Senthil ramna avatar
    67 posts
    Member since:
    Mar 2010

    Posted 21 Sep 2010 Link to this post

    How do i generate a radtree view dynamically, i am using a masterpage in the page that i am trying to achieve this, also kindly let me know if i have to make any other changes if i am trying to achieve this if i am doing this in a Usercontrol.

    protected void Page_Load(object sender, EventArgs e)
        {
          if (!IsPostBack)
            {
                RadTreeView testTree = new RadTreeView();
                testTree.ID = "testTree";
                RadTreeNode node1 = new RadTreeNode();
                node1.Text = "Project";
                node1.Expanded = true;
                Image img1 = new Image();
                img1.ImageUrl = "~/images/top1.gif";
                node1.Controls.Add(img1);
      
                RadTreeNode node2 = new RadTreeNode();
                node2.Text = "Process";
                Label lblprocess = new Label();
                lblprocess.Text = "MisTesting";
                node2.Controls.Add(lblprocess);
      
                this.Controls.Add(testTree);
            }
        }

    please let me know if i am going wrong somewhere...
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Sep 2010 Link to this post

    Hello Senthil,


    I believe you are in right direction. And the only change that I made is adding the control to a container (PlaceHolder/Form/Panel etc) and adding the nodes to Treeview (I guess you missed adding nodes to treeview).
    Add/Remove/Disable Nodes



    -Shinu.
  3. Senthil ramna
    Senthil ramna avatar
    67 posts
    Member since:
    Mar 2010

    Posted 21 Sep 2010 Link to this post

    Thanks for the reply Shinu will add control to the place holder.
    Also wanted to know if there is a property to keep the nodes expanded, like in ExpendDepth = FullyExpand.
  4. Yana
    Admin
    Yana avatar
    4916 posts

    Posted 21 Sep 2010 Link to this post

    Hi Senthil,

    You can use ExpandAllNodes() method of the treeview for this.

    Greetings,
    Yana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Senthil ramna
    Senthil ramna avatar
    67 posts
    Member since:
    Mar 2010

    Posted 21 Sep 2010 Link to this post

    Thanks for the reply Yana.
    With reference to this example http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/loadondemandmodes/defaultcs.aspx
    where should i call the method i.e. Radtreeview1.ExpandAllNodes()  because i am in a fix as, where to call it...
  6. Yana
    Admin
    Yana avatar
    4916 posts

    Posted 21 Sep 2010 Link to this post

    Hello Senthil,

    This online demo shows different load-on-demand modes of the treeview - the goal is not to load the whole treeview at once, but only when the user expands certain nodes. There's no point to use load-on-demand when the treeview should be expanded on page load. Please explain in more details your requirements.

    Regards,
    Yana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Senthil ramna
    Senthil ramna avatar
    67 posts
    Member since:
    Mar 2010

    Posted 21 Sep 2010 Link to this post

    Thanks for your reply Yana, but i did not find the video link you suggested i refer to.
    My requirement is that when the page loads, i want to keep all the nodes expanded.
    The goal is to load the entire tree view at once with all the nodes expanded.
    Please suggest whether this could be achieved.
  8. Yana
    Admin
    Yana avatar
    4916 posts

    Posted 24 Sep 2010 Link to this post

    Hello Senthil,

    I'm sorry for not being clear enough.

    I meant the same online demo that you referenced in your previous reply about load-on-demand modes  - http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/loadondemandmodes/defaultcs.aspx
    I wanted to explain that it's not suitable in your case.

    You can use the approach shown in this example - bind the treeview to a datasource and use DataBindings to set Expanded property of all the nodes to true. Please try it and let us know the result.

    Kind regards,
    Yana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top