Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Table Sort 2 Columns
Table Sort 2 Columns [message #1831918] Wed, 02 September 2020 17:58 Go to next message
Luis Nothvogel is currently offline Luis NothvogelFriend
Messages: 56
Registered: October 2019
Member
Hi there,

So I have got 2 Column that are important to my sorting. The first one would be a Integer column where I just sort descending. Now comes the Problem the second column i have which is important for sorting is a string column. Now I want that rows with the same string in that column are "together" so that they are next to each other regardless of the integer column. The rows with the same string would sort of be a group. I tried using the sort index but i it didnt quit work the way i described it.

Is there a scout inbuild way to do this?

Example:

Integer , String, other ...
Row 1: 5 ,a ,....
Row 2: 2 ,a ,....
Row 3: 4 ,b ,....

Regards,
Luis
Re: Table Sort 2 Columns [message #1831923 is a reply to message #1831918] Thu, 03 September 2020 06:30 Go to previous messageGo to next message
Arthur van Dorp is currently offline Arthur van DorpFriend
Messages: 48
Registered: October 2015
Member
Hi Luis

On your String column add a getConfiguredSortIndex() method and return 1, for the Integer column a sort index method which returns 2. For the latter to sort descending add a method getConfiguredSortAscending() which return false. That should yield the Table you've described.

Alternatively you could just add the sorting as described on your integer column and add a getConfiguredGrouped() on your String column.

For an example you could have a look at https://scout.bsi-software.com/widgets/?dl=widget-hierarchicaltablefield and its code under https://github.com/BSI-Business-Systems-Integration-AG/org.eclipse.scout.docs/blob/releases/10.0/code/widgets/org.eclipse.scout.widgets.client/src/main/java/org/eclipse/scout/widgets/client/ui/forms/HierarchicalTableFieldForm.java

Have fun.
Re: Table Sort 2 Columns [message #1831940 is a reply to message #1831923] Thu, 03 September 2020 11:39 Go to previous messageGo to next message
Luis Nothvogel is currently offline Luis NothvogelFriend
Messages: 56
Registered: October 2019
Member
Hi Arthur,

Thank you for your answer. But thats not quit what i want. As you can see in the first Screenshot i tried just sorting by these 2 columns. The string column certainly is correct but now its not sorted after the factor column. I also tried your second idea with the grouping as you can see in the second Screenshot. Here i dont need the "sum" row that gets generated and the second problem aswell here is that factor column sort is activ but it just sorts these sums columns.

I mean i can always sort them manually but that isnt very good performance wise. Isnt there a way to somehow tag rows to tell the table that these need to stay together?

  • Attachment: sort2.png
    (Size: 4.33KB, Downloaded 62 times)
  • Attachment: grouped.png
    (Size: 9.02KB, Downloaded 60 times)
Re: Table Sort 2 Columns [message #1831942 is a reply to message #1831940] Thu, 03 September 2020 11:56 Go to previous messageGo to next message
Arthur van Dorp is currently offline Arthur van DorpFriend
Messages: 48
Registered: October 2015
Member
I don't understand yet what you want to achieve. In your first screenshot the rows are grouped by the Number column and within each group the rows are sorted descending regarding the Factor column. That's how I understood what you wanted to achieve. Is there some additional sort order on those (implicitly by the first sort order generated) groups that you want?

[Updated on: Thu, 03 September 2020 11:57]

Report message to a moderator

Re: Table Sort 2 Columns [message #1831945 is a reply to message #1831942] Thu, 03 September 2020 12:25 Go to previous messageGo to next message
Luis Nothvogel is currently offline Luis NothvogelFriend
Messages: 56
Registered: October 2019
Member
Ok maybe it was a bit complicated. Let me try to explain. Overall the table should be ordered after the factor column. Highest top, lowest bottom. So far so good. Now i have some rows with the same string value in a column. I want these to be next to each other regardless of their factor.

Example:

Factor | String

5 | a
4 | b
4 | b
3 | b
1 | b <-- this wouldnt normally be there if i only sort by factor. But it has the same string as another row with a higher factor and thats why it should be "grouped" here
2 | c <- this row doesnt belong to the "b" group therefore it is sorted normally after the its factor

I hope it is now understandable
Re: Table Sort 2 Columns [message #1831946 is a reply to message #1831945] Thu, 03 September 2020 12:35 Go to previous messageGo to next message
Arthur van Dorp is currently offline Arthur van DorpFriend
Messages: 48
Registered: October 2015
Member
Ah, so basically you want to group the rows by the string and you want those groups to be sorted among each other by max(Factor) of each group within each group you would sort by Factor again. I would introduce a hidden column maxFactorOfGroup, give that column sort index 1, String sort index 2 and Factor sort index 3.

Your table would look like this:
maxFactorOfGroup (hidden)|Factor|String
5 | 5 | a
4 | 4 | b
4 | 4 | b
4 | 3 | b
4 | 1 | b
2 | 2 | c
Re: Table Sort 2 Columns [message #1832050 is a reply to message #1831946] Mon, 07 September 2020 12:16 Go to previous message
Luis Nothvogel is currently offline Luis NothvogelFriend
Messages: 56
Registered: October 2019
Member
Thank you for the answer. That should do the trick :).
Previous Topic:Get IP Address from Client Session
Next Topic:Build Error
Goto Forum:
  


Current Time: Fri Apr 19 08:37:22 GMT 2024

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

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

Back to the top