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

Generate radtreeview dynamically

7 Answers 360 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Senthil ramna
Top achievements
Rank 1
Senthil ramna asked on 21 Sep 2010, 05:00 AM

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...

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Sep 2010, 07:15 AM
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.
0
Senthil ramna
Top achievements
Rank 1
answered on 21 Sep 2010, 07:37 AM
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.
0
Yana
Telerik team
answered on 21 Sep 2010, 07:56 AM
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
0
Senthil ramna
Top achievements
Rank 1
answered on 21 Sep 2010, 08:07 AM
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...
0
Yana
Telerik team
answered on 21 Sep 2010, 03:14 PM
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
0
Senthil ramna
Top achievements
Rank 1
answered on 22 Sep 2010, 04:52 AM
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.
0
Yana
Telerik team
answered on 24 Sep 2010, 10:17 AM
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
Tags
TreeView
Asked by
Senthil ramna
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Senthil ramna
Top achievements
Rank 1
Yana
Telerik team
Share this question
or