Home - Forums-.NET - FlyTreeView (ASP.NET) - findByValue method

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

findByValue method
Link Posted: 20-Sep-2006 23:06
Hi.

i want to expand one node of flyTreeView 2.0 through another frame. I have the VALUE of the node to expand.

i tried as below

function onSelectedNodeChangedHandler(sender, oldNode, node)
{
     currentNode = sender.getSelectedNode();
     alert(currentNode.getValue());
     var sourceNode = currentNode.getTreeView().findByValue(currentNode.getValue());
     sourceNode.expand();
}

it does not works. i got \"object does not support this property or method\"

findByID works but findByValue gets this error.  I must use findByValue.

i used onSelectedNodeChangedHandler event only to try this code.

how can i make it work? can you help me? thanks.
Link Posted: 21-Sep-2006 01:38
The findByValue() function returns array of nodes, or empty array if nothing was found. The reason is that Value is not unique field.

So your code should look like the following

var sourceNodes = currentNode.getTreeView().findByValue(currentNode.getValue());
if (sourceNodes.length > 0)
    sourceNodes[0].expand();

also, if you're trying to look for the node recursively, you should probably need to use the findAll method:
currentNode.getTreeView().findAll(function(node) { return node.getValue() == 'requiredValue'; })