Welcome Guest Search | Active Topics | Sign In | Register

Change the Selected node (Client Side) Options
THoMaSiN
Posted: Wednesday, December 5, 2007 8:26:27 AM
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
eo_support
Posted: Wednesday, December 5, 2007 8:44:10 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
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
THoMaSiN
Posted: Wednesday, December 5, 2007 8:55:54 AM
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); // &lt;&lt; -- 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 !!

eo_support
Posted: Wednesday, December 5, 2007 8:58:06 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Ah! The document is wrong. Try selectNode instead of setSelectedNode.
THoMaSiN
Posted: Wednesday, December 5, 2007 9:02:14 AM
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 !!
eo_support
Posted: Wednesday, December 5, 2007 9:54:34 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
There shouldn't be any problem for us to add it, those make perfect sense.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.