Problem with treeview

A

Alessandro Di Rago

I have a treeview's tree:

<form id="showtree" name="showtree" method="post" runat="server">
<iewc:TreeView id="TreeView" runat="server" AutoPostBack="true"
SelectExpands="false" EnableViewState="True" Width="1000px"></iewc:TreeView>
</form>

i wish create a javascript's function that, on the onclick event, give me
the attribute of the clicked node. Someone know how developed this
javascript function?
Thank you
 
R

Rajiv

Hi,

Node has a property called NavigateURL. Set this to the
javascript function.

Meanwhile, which attribute of the clicked node are you
interested in? Let me and I can help you with the js
function.

Cheers!
Rajiv
 
A

Alessandro Di Rago

Rajiv said:
Hi,

Node has a property called NavigateURL. Set this to the
javascript function.

Meanwhile, which attribute of the clicked node are you
interested in? Let me and I can help you with the js
function.

i want the text attribute, my problem is that i do not succeed to recognize
the clicked node with the js function.
Thanks
 
R

Rajiv

Hi,

Try with the NavigateURL property of Node. Set the
navigateurl to "javascript:myfunction('nodenamehere');".
In your page have a function:
<script language=javascript>
function myfunction(node){
alert(node);
}
</script>

try this.. should work.

Cheers!
Rajiv
 
A

Alessandro Di Rago

Rajiv said:
Hi,

Try with the NavigateURL property of Node. Set the
navigateurl to "javascript:myfunction('nodenamehere');".
In your page have a function:
<script language=javascript>
function myfunction(node){
alert(node);
}
</script>
in navigateurl property i have already a link, take to the database. i found
this function:

function myfunc()
{
var SelectedNode;
// This gives you the node that is clicked
SelectedNode=TreeView1.getTreeNode
(TreeView1.clickedNodeIndex);
// just checks and returns a property of the node
if (SelectedNode!=null)
{
alert(SelectedNode.getAttribute("text"));
}
}

<form id="showtree" name="showtree" method="post" runat="server">
<iewc:TreeView id="TreeView" runat="server" AutoPostBack="true"
SelectExpands="false" EnableViewState="True" Width="1000px"></iewc:TreeView>
</form>

But it does not work, the error is generated on
"SelectedNode=TreeView1.getTreeNode(TreeView1.clickedNodeIndex);"
 
N

Nicolas Chevet

Try this.
in the code behind :
TreeView1.Attributes.Add("onselectedindexChange", "mafonction();")

And in the page:
<script language="javascript">
function mafonction(){
SelectedNode = event.srcElement.getTreeNode(event.treeNodeIndex);
SelectedNode.getAttribute('nodedata');
}
</script>
 
A

Alessandro Di Rago

Nicolas Chevet said:
Try this.
in the code behind :
TreeView1.Attributes.Add("onselectedindexChange", "mafonction();")

And in the page:
<script language="javascript">
function mafonction(){
SelectedNode = event.srcElement.getTreeNode(event.treeNodeIndex);
SelectedNode.getAttribute('nodedata');
}
</script>

When i click on the node, with the onselectedindexChange event, it not work
nothing. I use the onclick event:
TreeView1.Attributes.Add("onclik", "mafonction();")
in this way, when i click on the node, is called the js function but is
generated an error on the
"event.srcElement.getTreeNode(event.treeNodeIndex);". The error is method
not supported by object.
Why?
 
M

Manfred Braun

Hi,

I have not read all here, but regard, in JScript, the event-name is
case-senstive is is named "onselectedindexchange". This works for me!

Best regards,
Manfred Braun

(Private)
Mannheim
Germany

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

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top