Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7652039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:39:45+00:00 2026-05-31T11:39:45+00:00

I have a Java List containing objects with hierarchical data (id, name, parentId) and

  • 0

I have a Java List containing objects with hierarchical data (id, name, parentId) and need to generate an HTML tree structure (using something like DynaTree) with expand/collapse features. All the examples I’ve seen require generating nested <ul> structures to represent parent/child/…/n-child/ hierarchies, etc.

I could convert the data to build this structure. But, I’d think this data format would work in its current form (id/name/parentId). Is there a jquery API that can handle this data?

here is an abbreviated example..

//Category has an id, name, parentId
List<Category> categoryTree = new ArrayList<Category>();
categoryTree.add(new Category(1, 'root', null));
categoryTree.add(new Category(2, 'colors', 1));
categoryTree.add(new Category(3, 'blue', 2));
categoryTree.add(new Category(4, 'red', 2));
categoryTree.add(new Category(5, 'shapes', 1));
categoryTree.add(new Category(6, 'round', 5));

//now, I need to convert this to dynamic javascript to build the tree structure (<ul>, etc)

I’ve used SmartGWT like this before and its trivial to convert this into a tree node structure (see this example). I’d think there was a jQuery API to do the same…perhaps not

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:39:46+00:00Added an answer on May 31, 2026 at 11:39 am

    Here’s a demo that might help

    http://jsfiddle.net/charlietfl/pCsZ3/

    It parses infinitely deep object with not a lot of jQuery and using only one append to DOM for the whole tree

    If parsing from list it would be more efficent creating the object first anyway, otherwise you would be doing a lot of extra appending to DOM which isn’t very efficient

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java program that is supplied a directory name, gets a list
I have a List of Java objects on my server which is sent to
Say you have a linked list structure in Java. It's made up of Nodes:
I have some model objects I'm using in my Java client application. Later these
I have a checkbox node tree using java Swing. My objective is to select
In a java class, am using an arraylist say reports containing list of all
I have string containing a list of name like below: John asked Kim, Kelly,
I have a list of links, containing links to html and xml pages, how
I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int
So I have something like the following in Java: private List<SomeType>variable; // ....variable is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.