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

How to find invisible tree nodes?

1 Answer 68 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Affan
Top achievements
Rank 1
Affan asked on 02 Dec 2011, 04:54 PM
Hi,

I am using treeview and in my tree there are few nodes that are visible and few that are not visible depending upon their type. I am trying to find the invisible nodes from client side code using findNodeByText/findNodeByValue functions but it always returns null. is it possible to get hidden nodes? if not then what is the workaround?

1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 02 Dec 2011, 06:21 PM
Hello Affan,

You can't access the nodes which have their Visible proserty set to "false", because they are not sent to the client by the server. To send all of the nodes to the server, and still have some of them hidden, use the following method:

1. Instead of using  visible="false", use a custom property with a unique name, for example IsClientVisible="false"
2. Add the following function to the OnClientLoad event of the treeview:

unction onClientLoad(sender){
    var tree = sender;
    var nodes = tree.get_allNodes();
    for (var i = 0; i < nodes.length; i++) {               
        var isVisible = nodes[i].get_attributes().getAttribute("IsClientVisible");
        if(isVisible!=null && isVisible=="false")
        {
            nodes[i].set_visible(false);
        }
    }
}

Hope this helps.

Kind regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TreeView
Asked by
Affan
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or