Hide node at runtime

4 posts, 1 answers
  1. Adam Hubble
    Adam Hubble avatar
    74 posts
    Member since:
    Jan 2008

    Posted 24 Jul 2009 Link to this post

    Hi,

    I am binding radtreeview to a sitemap file. Is it possible to hide specific nodes at runtime - how should I go about this?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Jul 2009 Link to this post

    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.
  3. Adam Hubble
    Adam Hubble avatar
    74 posts
    Member since:
    Jan 2008

    Posted 27 Jul 2009 Link to this post

    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
  4. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 27 Jul 2009 Link to this post

    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.
Back to Top