Solved

Simulate Treeview Root node click

Posted on 2009-05-18
5
1,044 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 29

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 29

Expert Comment

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

Please post some more details.


0
 
LVL 29

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 29

Expert Comment

by:Pravin Asar
ID: 24443135
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

617 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