aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to write a javascript function to exapand/collapse all nodes in a TreeMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to write a javascript function to exapand/collapse all nodes in a TreeMenu" Watch "How to write a javascript function to exapand/collapse all nodes in a TreeMenu" New topic
Author

How to write a javascript function to exapand/collapse all nodes in a TreeMenu

Keerthi Chandhu
Greenhorn

Joined: Feb 03, 2009
Posts: 16
Hi,

I am trying to write a javascript function to collapse/expand all nodes in a tree menu.
Could anyone please give me some idea how to write this function?

Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

Where's your code?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3219
    
  49

Agree with Bear,

It depends on your implementation.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
if you need a starting place:
  • onclick
  • obj.style.display="none"


  • Eric
    Keerthi Chandhu
    Greenhorn

    Joined: Feb 03, 2009
    Posts: 16
    Hi,

    Please find my code.


    I am trying to write a function like
    If user clicks a collapse all button it should collapse entire tree view nodes.
    I do not understand how to check the condition to find whether a tree is expanded or not. if( tree.Expanded){

    Any suggestions would be appreciated.


    Thank you.
    Eric Pascarello
    author
    Rancher

    Joined: Nov 08, 2001
    Posts: 15376
        
        6
    And what is the tree that you are using? There are 1000's of them out there.

    Eric
    Keerthi Chandhu
    Greenhorn

    Joined: Feb 03, 2009
    Posts: 16
    I am using java script and jsp to create a TreeMenu which is dynamically driven from database.
    I am using JSP and Jdbc to get tree node names from database and calling javascript fuction to create the tree and able to create tree.
    I am looking for help in writing expand all/collapse all nodes function for a treemenu.

    I hope this the information you are looking for,else I can provide more information.


    Thank you.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
     
    subject: How to write a javascript function to exapand/collapse all nodes in a TreeMenu