• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need to create tree structure (parent node child node)

 
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to create a tree structure in JSP which has parent child node relationship.Also this should expand and collapse/ Please advice how to create this.I am posting this is Javascript forum as on searching on internet I found that this can be done only throught javascript but I did not get any example on how to do it.

Thanks.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why reinvent the wheel? Search for JavaScript tree control.
 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I searched for it, I got results for Jquery in the results. I do not know jquery. I hope it can be done in simply javascript also.

thanks
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using jQuery will make things much easier. I'd suggest getting comfortable with jQuery.

And yes, when you are searching for JavaScript plugins, chances are that they are going to be based on jQuery.
 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am calling createTree.js java script in my JSP but not able to get the tree. Below are my JSP page and createTree.js

treeView.jsp



createTree.js




 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
may be I am doing some mistake while passing parameter from JSP to javascript
 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried doing the below changes but still no success

treeView.jsp


maketree.js






 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this working.Now I need this to be dynamic. My UI,LI elements to be dynamically creating the tree.E.g I want the user to be able to add the child or parent to the tree dynamically. Currenly in my tree parent and child are hardcoded.How to make that dynamic.




I need the user to be able to add parent and child dynamically.How to do that.Please advice.
thanks.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That depends upon how you are going let the user specify what is to happen. Once you know that, adding elements to the list elements is easy with jQuery.
 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Requirement is like this :

1) User clicks on button Add parent-->A parent node is created to being the tree structure
2) User click on button Add child--> The child node is added to the parent node with parent child relation.(Tree control collapse,expand).

The tree control collapse expand is working fine for me. Now I am trying to build this on user clicks 1) and 2).


I know how to add a button, text or radioButton to fileds by adding an say to form and later using

(in case I need to add textbox dynamically.
But in my case I need to add UI and LI dynamically. If i replace text above with ui or li it doesnt work.



Please advice how to add these ui,li dynamically to build tree dynamically.

thanks.
 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also used above was



Please advice.
 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adding LI to UI dynamically using java script is Working Fine for me as below but what I need is I need to insert another UI inside LI Inside this UI.


Doing above dynamically is working fine for me..But doing below dynamically is not working fine:



Below is the code I am trying.





 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the above working but using below code.



Its working fine.thanks
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic