Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Sorting in Tree List Breaks the Tree Structure
Sorting in Tree List Breaks the Tree Structure [message #1110829] Tue, 17 September 2013 11:30 Go to next message
Ali Malik is currently offline Ali MalikFriend
Messages: 27
Registered: August 2013
Junior Member
Hi,

I have been working on the Tree List.
I have a Tree Table with 4 columns.

Sorting works fine generally on it.

But in a case, where there are 2 parent nodes (both same name) and both have 5 children(all with same name), so when I apply sorting on this table, it breaks the tree.
For example:

Before:

Parent
-Child
-Child
-Child
-Child
-Child

Parent
-Child
-Child
-Child
-Child
-Child


After:

Parent
Parent
-Child
-Child
-Child
-Child
-Child
-Child
-Child
-Child
-Child
-Child


As you can see it has mixed up the children of the two different nodes.

Why is that?

However, when I turn off the sorting, the children could be shown with their original parents.

Regards,
Ali Ahmad Malik
Re: Sorting in Tree List Breaks the Tree Structure [message #1110848 is a reply to message #1110829] Tue, 17 September 2013 12:01 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Well as far as I remember, this is caused because the tree is only showed correctly if the ordering is correct. So the children need to be below the parent. I assume the comparator you are using is sorting the values themselves without taking the parent-child-relationship into account. As I'm currently working on some other issues I'm not able to dig into this in more detail. Have a look at our examples to get a clue.
Re: Sorting in Tree List Breaks the Tree Structure [message #1111357 is a reply to message #1110848] Wed, 18 September 2013 05:25 Go to previous messageGo to next message
Ali Malik is currently offline Ali MalikFriend
Messages: 27
Registered: August 2013
Junior Member
I did take parent-child relation into account.
I compare the nodes only if their parent is same, otherwise I return 0.
It still doesn't work!
Re: Sorting in Tree List Breaks the Tree Structure [message #1111505 is a reply to message #1111357] Wed, 18 September 2013 10:04 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
One thing is sorting via SortHeaderLayer, the other thing is sorting in the tree to create the tree structure. The later is done by TreeList.Format.getComparator()

Are you aware of that and did you take that into account?
Re: Sorting in Tree List Breaks the Tree Structure [message #1111511 is a reply to message #1111505] Wed, 18 September 2013 10:11 Go to previous messageGo to next message
Ali Malik is currently offline Ali MalikFriend
Messages: 27
Registered: August 2013
Junior Member
Yes, I overrode the getComparator() in my class that implements TreeList.Format
I didn't change the SortHeaderLayer
Re: Sorting in Tree List Breaks the Tree Structure [message #1111520 is a reply to message #1111511] Wed, 18 September 2013 10:27 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Maybe that is the issue. If you are sorting via column header, the comparator in the SortConfiguration is applied. And that doesn't know about your tree structure.
Previous Topic:Changing parent of a node in the tree table
Next Topic:TextCellEditor more like Excel
Goto Forum:
  


Current Time: Fri Mar 29 11:43:12 GMT 2024

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

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

Back to the top