Solved

Simulate Treeview Root node click

Posted on 2009-05-18
5
1,031 Views
Last Modified: 2012-05-07
Hi Experts,

I've found some good posts in EE on capturing some of the events but what i need to do is simulate the click on the root node of my treeview in javascript on the client. I'm hoping this is going to be simple and quick ! I've had a look around the treeview in firebug but can't see anything obvious, not to this beginner anyway ;-)

thanks
0
Comment
Question by:stevejebson
  • 4
5 Comments
 
LVL 28

Expert Comment

by:Pravin Asar
Comment Utility
if root node has id assigned, you can get object handle by inquiry

 document.getElementById()

Once you have object, trigger click call


e.g

<html>
<head>
<script type="text/javascript">
function clickRoot()
  {
  document.getElementById('root').click()
  }
function alertMsg()
  {
  alert("Root  was clicked!")
  }
</script>
</head>
<body onload="clickRoot()">
<ul id="root" onclick="alertMsg();">Root
   <li>Section 1
     <ul>
        <li>Test Mode Procedures</li>
         <li>Diagnostic Procedures</li>
        <li>Other Procedures
          <ul>
             <li>Log Analysis</li>
             <li>Error Message Analysis</li>
             <li>Miscellaneous Procedures</li>
               <ul>
                  <li>Emergency Procedures</li>
                  <li>Power-Off Procedures</li>
                </ul>
          </ul>
        </li>
     </ul>
   </li>
   <li>Section 2
     <ul>
        <li>Functional Description
          <ul>
             <li>Power Distribution Function</li>
             <li>System Ready Function</li>
             <li>Emergency Stop Function</li>
          </ul>
        </li>
         <li>Tracking Function</li>
        <li>Other Functions</li>
     </ul>
   </li>  
</ul>
</body>
</html>
0
 
LVL 28

Expert Comment

by:Pravin Asar
Comment Utility
By the way , which Javascript /Treeview code you are using ?

Please post some more details.


0
 
LVL 28

Expert Comment

by:Pravin Asar
Comment Utility
0
 
LVL 1

Accepted Solution

by:
stevejebson earned 0 total points
Comment Utility
Hi pravinasar,

Apologies for delay, yes i am using the <asp:treeview> and i've been trying to code a .click() function in javascript to replicate. However it appears that there is no .click() method on an element once i've got hold of it e.g. ele = doc.getelementbyid('rootnoteid'); there is no method of .click() well not in my flavour.

What i have been ablt to ascertain is that i can replicate the click actions by coding...


__doPostBack('TreeView1','valuefromrootnode');

Open in new window

0
 
LVL 28

Expert Comment

by:Pravin Asar
Comment Utility
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now