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

Hide node at runtime

3 Answers 130 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Adam Hubble
Top achievements
Rank 1
Adam Hubble asked on 24 Jul 2009, 03:51 PM
Hi,

I am binding radtreeview to a sitemap file. Is it possible to hide specific nodes at runtime - how should I go about this?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Jul 2009, 10:33 AM
Hi Matt Davis,

You can find out the specific node and then set the Visible property to False in order to hide the node.

C#:
 
protected void Button1_Click(object sender, EventArgs e)  
{  
    RadTreeNode foundNode = RadTreeView1.FindNodeByText("RadTreeNode Text");  
    if (foundNode != null)  
    {  
        foundNode.Visible = false;  
    }  

Thanks,
Princy.
0
Adam Hubble
Top achievements
Rank 1
answered on 27 Jul 2009, 11:11 AM
Hi Princy, thank you for the response. Unfortunately this does not seem to work for me as I'm doing this on pageLoad and my nodes collection always seems to be zero.

I do:

dim trv as radtreeview = DirectCast(genMenuRadPnlBar.FindItemByValue("treeViewTemplate").FindControl("generalRadTreeView"), RadTreeView)

trv does get the treeview passed to it, but the nodes collection is always zero. I've tried this at a few different stages of the page life cycle (which I assume might be the issue) but no luck....

Obviously if I try your code at the moment, foundNode will always be null
0
Accepted
Atanas Korchev
Telerik team
answered on 27 Jul 2009, 01:59 PM
Hello Matt Davis,

I presume you are using a declarative datasource do databind the treeview. In this case the nodes are populated later than page_load. I suggest you subscribe to the DataBound event of the treeview and use the suggested code there. That event is fired after the treeview is databound so the Nodes collection will be populated.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Adam Hubble
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Adam Hubble
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or