| Author |
need to create tree structure (parent node child node)
|
Monica. Shiralkar
Ranch Hand
Joined: Jul 07, 2012
Posts: 186
|
|
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.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
|
Why reinvent the wheel? Search for JavaScript tree control.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Monica. Shiralkar
Ranch Hand
Joined: Jul 07, 2012
Posts: 186
|
|
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
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
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
Joined: Jul 07, 2012
Posts: 186
|
|
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
Joined: Jul 07, 2012
Posts: 186
|
|
|
may be I am doing some mistake while passing parameter from JSP to javascript
|
 |
Monica. Shiralkar
Ranch Hand
Joined: Jul 07, 2012
Posts: 186
|
|
I tried doing the below changes but still no success
treeView.jsp
maketree.js
|
 |
Monica. Shiralkar
Ranch Hand
Joined: Jul 07, 2012
Posts: 186
|
|
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
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
|
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
Joined: Jul 07, 2012
Posts: 186
|
|
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
Joined: Jul 07, 2012
Posts: 186
|
|
Also used above was
Please advice.
|
 |
Monica. Shiralkar
Ranch Hand
Joined: Jul 07, 2012
Posts: 186
|
|
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
Joined: Jul 07, 2012
Posts: 186
|
|
I got the above working but using below code.
Its working fine.thanks
|
 |
 |
|
|
subject: need to create tree structure (parent node child node)
|
|
|