treeview SelectedIndexChange problem

S

steven shingler

Hi all

I've a treeview made up of images in a directory structure

When the image name is clicked on in the tree, i'd like to be able to
popup the image in a new window

so far I've got a javascript function to handle my SelectedIndexChange
event:

function returnSelectedIndexCh(){
var str = "";
var index = document.forms(0).all("TreeView1").selectedNodeIndex;
var currentNode = document.forms(0).all("TreeView1").getTreeNode(index);
strLoc += currentNode.getAttribute("Text");
alert(str);
}

this gives me the name of the image, but I need the parent information
too, so I can reference the directory of the image.

I was hoping for currentNode.getAttribute("Parent"), but that was just
one bridge too far.

A client-side solution would be brilliant, so as to avoid postback,
but if anyone can see a server-side solution that would be great too.

Many Thanks for taking a look!
Steven
 
M

Manfred Braun

Hi,

I really understand only a small bit of all the things with the treeview,
but the nodeindex, so far I think, would help. The nodeindex is a string
like "1.2.3.4", so if you are at the bottom, you know, that "1.2.3" is your
parent.

Hope, this helps.
Best regards,
Manfred Braun

(Private)
Mannheim
Germany

mailto:[email protected]
(Remove the anti-spam-underscore to mail me!)
 
S

steven shingler

Hi Manfred, thanks for replying
whilst looking at the nodeindex, I found you can get the Parent attribute like this:

var tree = window.event.srcElement
var nodeIndex = tree.clickedNodeIndex;
var node = tree.getTreeNode(nodeIndex);
var parent = node.getParent().getParent().getParent().getAttribute("Text");

which is quite cool too!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top