Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 17:59 Go to next message
Amol Salunke is currently offline Amol SalunkeFriend
Messages: 16
Registered: March 2015
Junior Member
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 18:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
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 08:59 Go to previous messageGo to next message
Amol Salunke is currently offline Amol SalunkeFriend
Messages: 16
Registered: March 2015
Junior Member
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 09:31 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
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 10:37 Go to previous message
Amol Salunke is currently offline Amol SalunkeFriend
Messages: 16
Registered: March 2015
Junior Member
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: Thu Apr 25 06:49:00 GMT 2024

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

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

Back to the top