|
Rank: Member Groups: Member
Joined: 12/5/2007 Posts: 27
|
Hello,
I'm trying to change the selected Node programmatically on the client side to the next Node after the selected one.
For that I would like to get the currently selected node and then find out which one is the next one.
Is there any function to obtain the currently selected node?
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, There isn't a simple function to return the selected node. However you can handle ClientSideOnItemClick event to "remember" the last clicked node, and generally that is the selected node. If you want to be absolute sure, you would need to walk through all the nodes and call getSelected() on each node. Once you have the selected node, you you can use the following code to move the selected node to the next one:
Code: JavaScript
var index = selectedNode.getIndex();
var group = selectedNode.getParentGroup();
if (index < group.getItemCount() - 1)
{
selectedNode = group.getItemByIndex(index + 1);
TreeView1.setSelectedNode(selectedNode);
}
Thanks
|
|
Rank: Member Groups: Member
Joined: 12/5/2007 Posts: 27
|
Yeah, I thought of that, the thing is that I was trying to use the function setSelectedNode and this is the result I get:
Code: JavaScript
function SelectNext ()
{
var tree = eo_GetObject("TheTreeView");
var first = tree.getTopGroup().getItemByIndex(0);
alert(first.getText());
tree.setSelectedNode(first, false); // << -- Error
return false;
}
result: Object doesn't support this property or method ( i see the alert showing ... nothing after that) Thanks for your quick reply !!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Ah! The document is wrong. Try selectNode instead of setSelectedNode.
|
|
Rank: Member Groups: Member
Joined: 12/5/2007 Posts: 27
|
wow, that was totally true ...
Then I'm going to implement your solution :)
It would be very convenient to have a getSelectedNode for the tree object
and also If I can ask for more, getNextLeaf (byval node as TreeNode) which returns the next leaf object :)
Thanks !!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
There shouldn't be any problem for us to add it, those make perfect sense.
|
|