Solved

Simulate Treeview Root node click

Posted on 2009-05-18
5
1,037 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
ID: 24426874
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
ID: 24426885
By the way , which Javascript /Treeview code you are using ?

Please post some more details.


0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 24436030
0
 
LVL 1

Accepted Solution

by:
stevejebson earned 0 total points
ID: 24438819
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
ID: 24443135
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

911 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

25 Experts available now in Live!

Get 1:1 Help Now