Skip to main content



      Home
Home » Eclipse Projects » NatTable » Having issue with Mapping Child-Parent in Tree(Issue In Tree)
Having issue with Mapping Child-Parent in Tree [message #1723604] Tue, 16 February 2016 12:59 Go to next message
Eclipse UserFriend
I am using below code but it is not displaying the correct mapping with child-parent in tree.

@Override
public void getPath(List path, Object element)
{
path.add(element); // Adding Parent here
List children = element.getChildren(); // getting all required child.
if (children != null && children.size() > 0)
{
for (Object child : children)
{
path.add(child); // Looping on loop for all child
}
}
}

-----------------------------------------------------------------------------------------------------------------------
In above code I get the one object which has three child but it is not showing with under correct parent.
-----------------------------------------------------------------------------------------------------------------------
For example, I have data that I want to show in tree format like , parent 'A' which has three child 'B', 'C', 'D'.

I am expecting result as below
A
----B
----C
----D
but I gets as below (not expected)
A
---- B
--------- C
-------------- D
What should I do more to get desired output.

Re: Having issue with Mapping Child-Parent in Tree [message #1723609 is a reply to message #1723604] Tue, 16 February 2016 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Don't iterate over all children. The method is called for every object in the collection
Re: Having issue with Mapping Child-Parent in Tree [message #1723684 is a reply to message #1723609] Wed, 17 February 2016 03:59 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for your reply.

Try to add as collection (all children) but it gives me the same output.

am adding all in a list Instead of looping. as below.

path.addAll (children);

Am I missing anything?
Re: Having issue with Mapping Child-Parent in Tree [message #1723692 is a reply to message #1723684] Wed, 17 February 2016 04:31 Go to previous messageGo to next message
Eclipse UserFriend
You are thinking the wrong way. You need to look at this from the child point of view, not from the parent.
Re: Having issue with Mapping Child-Parent in Tree [message #1723831 is a reply to message #1723692] Thu, 18 February 2016 05:37 Go to previous message
Eclipse UserFriend
Thanks for your reply.. got it now.
Previous Topic:NatTable clear configuration
Next Topic:Default sorting when no explicit sort is applied
Goto Forum:
  


Current Time: Wed Jun 18 21:35:36 EDT 2025

Powered by FUDForum. Page generated in 0.04837 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top