J
JamesHead
Hi All,
I have a treeview control (built using server side code - talking to a db)
and I need to control the expansion of nodes on the client side.
I am currently using the following code:
<SCRIPT LANGUAGE="JavaScript">
function findNode(index)
{
var tree = document.getElementById('treeWPQ1');
//tree.expandLevel='2';
var arNode = index.split(".");
var ci;
for (ni in arNode)
{
if (ci !=null)
{
ci += "." + arNode[ni];
}
else
{
ci = arNode[ni];
}
var myNode = tree.getTreeNode(ci);
// alert('expanded: ' + myNode.getAttribute('expanded'));
// if(myNode.getAttribute('expanded')!=true)
// {
// myNode.setAttribute('expanded', true);
// }
}
tree.selectedNodeIndex=index;
return true;
}
</SCRIPT>
Using various combinations of commented lines of code, I can successfully
get the treeview to select a node. However, if this new selected node is not
shown (ie part of a collapsed branch), I want to be able to expand all parent
nodes so that my selected node is visible.
The commented code "myNode.setAttribute('expanded', true);" should set a
node to expanded. I can see that this might not work for leaf nodes (because
there isn't anything to expand), but I really need to ensure that a newly
selected item is "expanded into view".
I had this requirement fulfilled using server side code (and it was a piece
of cake to do), but the requirements won't tolerate a postback, so I need to
do this client side.
Any help much appreciated!
James
I have a treeview control (built using server side code - talking to a db)
and I need to control the expansion of nodes on the client side.
I am currently using the following code:
<SCRIPT LANGUAGE="JavaScript">
function findNode(index)
{
var tree = document.getElementById('treeWPQ1');
//tree.expandLevel='2';
var arNode = index.split(".");
var ci;
for (ni in arNode)
{
if (ci !=null)
{
ci += "." + arNode[ni];
}
else
{
ci = arNode[ni];
}
var myNode = tree.getTreeNode(ci);
// alert('expanded: ' + myNode.getAttribute('expanded'));
// if(myNode.getAttribute('expanded')!=true)
// {
// myNode.setAttribute('expanded', true);
// }
}
tree.selectedNodeIndex=index;
return true;
}
</SCRIPT>
Using various combinations of commented lines of code, I can successfully
get the treeview to select a node. However, if this new selected node is not
shown (ie part of a collapsed branch), I want to be able to expand all parent
nodes so that my selected node is visible.
The commented code "myNode.setAttribute('expanded', true);" should set a
node to expanded. I can see that this might not work for leaf nodes (because
there isn't anything to expand), but I really need to ensure that a newly
selected item is "expanded into view".
I had this requirement fulfilled using server side code (and it was a piece
of cake to do), but the requirements won't tolerate a postback, so I need to
do this client side.
Any help much appreciated!
James