Solved

Simulate Treeview Root node click

Posted on 2009-05-18
5
1,039 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Passport Expiry 3 44
Checkout Page Input Field not aligned 1 23
Adding Row and Cell on a table 14 20
Hide Table in merge 3 10
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

777 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