Home - Forums-.NET - FlyTreeView (ASP.NET) - Find associated Root Node using Javascript

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Find associated Root Node using Javascript
Link Posted: 28-Mar-2007 05:11
How can I find the root node ID associated to a particular child.  In my tree I have 4+ root nodes, and can only find them using findByValue(\"root\") , however this only works for the hardcoded root node, I need to be able to run subsequent code against whichever node is the root of the selected child.
Link Posted: 28-Mar-2007 05:42
Every node has getParent() method.

So using it you can create a simple recursive function like this:

function getRootNode(node)
{
    var parentNode = node.getParent();
    if (parentNode) {
         return getRootNode(parentNode);
    } else {
         return parentNode;
    }
}


So getRootNode(yourNode).getID() will return root ID.