Submitted by viking on 2022/07/31 13:54

I am grouping my items by one column ("Type"), and would like to sort the items within the groups based on another column ("ItemCreated"). Is this possible?

According to the manual here https://www.infoqubeim.com/drupal5/node/864, this does not seem to be possible?:

  1. None (Manual)
  2. Sort Bar
  3. Source Items Sort
  4. Group-By Bar
The sorting modes are mutually exclusive, so only one can be active at any one time.

I found a "workaround" by clicking on the "ItemCreated" column. However, this only works temporarily. The sorting is gone after a refresh, for example.

I am aware that can instead filter and sort using the source bar, but I prefer to keep the grouping. Is there another way?

 

Comments

I have the Group By bar and source item sort both turned on at the same time in the same grid.  My grid is in the "Source items (flat list)" display mode, and under Grid >  Sort I have "Group-By Bar" (option 4) active out of the four options above.  Underneath those options, I have "Sort Items" selected as the sorting mode.

In the source bar I have two sorting criteria entered. I also have a date filter turned on.

So I'm not sure what's excluding what, but I have the effects of both grouping and sorting working at the same time.

@Cyganet, I tried your settings (except for the filter) but it didn't work for me. The items are not sorted. Maybe because I Group by Tag and sort by Field?

It also seems to contradict the manual which states that you can only use either the Group-By Bar or the Source Items Sort. Maybe I am reading it wrong?

I don't know if this works with tags, since I don't use them. I work only with fields. Note that I don't sort by clicking on columns. 

I realise that my setup contradicts the manual, yet it works. 

@Cyganet,

I just discussed this with Pierre at the Coffee Shop. He suggested to try to first apply the source-bar sort and then add the grouping. I tried it, but it still didn't work for me:

z

I wish that I had your magic....
If you have time, would it be possible for you to create a dummy database with a few items to show how you did it?

Hi Viking,

Here is a dummy database in which I have made a copy of my working setup. Steps to create this were:

  1. File > New > New Blank IQBase, called "GroupSortDemo"
  2. Grid > New Grid, called "WorkingData"
  3. Column > Add Columns > Add New > Text Column, called "GroupInfo"
  4. Column > Add Columns > Done
  5. Fill in some example items in the WorkingData grid (in my case, with parents and children)
  6. Grid > New Grid, called "DoneLog". Options > Set Custom Grid Source, Items with value from "Done"
  7. Go to "DoneLog"  grid
  8. Grid > Source Items (Flat List)
  9. Grid > Context Parents > (None)
  10. Column > Add Columns > ItemParent, ItemModified, GroupInfo
  11. Grid > Sort > Group-By Bar
  12. Drag GroupInfo to the Group-By Bar
  13. GroupInfo Column, right-click, Hide Column
  14. Click on folder icon in Source Bar
  15. Click on Sort ON
  16. In Sort box, fill in "[Done] DESC, [ItemModified] DESC"

And unfortunately, it didn't work because the sort order gets ignored in this new file.  Even though my actual working setup DOES work, and when I change the sort criteria it will sort them properly. So I did some more fiddling, and here is how I got it to work:

  1. In the Sort box, fill in "[GroupInfo], [ItemParent], [ItemModified]", or whatever sort order you want.  Make sure the first sort criterion is the same one as the Group-By column and the same order ASC or DESC
  2. If it doesn't respond, click Sort OFF, then Sort ON again to make it trigger

The demo file is attached. Hope this helps.

Thank you so much Cyganet!
I got it working on my demo file with screenshot shown above. The "trick" was, as you said, to add the [GroupInfo] in the Source Item Sort.
Thus, in my case, I had "ToGroup, Date" in the Source Item Sort instead of just "Date":
z

Unfortunately, it didn't work in my working file because I am grouping by Tags and sort by date. I believe that I found a bug;

Without any grouping:
1. If I only enter "Date" in the Source Item Sort, the items are properly sorted by Date
2. If I only enter "#TagGroup" in the Source Item Sort, the items are properly sorted by #TagGroup
3. If I enter "#TagGroup" followed by "Date" in the Source Item Sort, the items are still properly sorted; first by #TagGroup and then by Date:

z

However, I then get an error:

z
 

If I now group by bar as well, it doesn't work (the items are not sorted by date):

z

 

EDIT1: Fixed some Typos above

EDIT2: P.s. For testing purposes, I realize that it was a mistake to put the date in ascending order as the items1-9 were created. However, when changing the dates, the items still sorted properly when using the "ToGroup, Date" in the Source Item Sort "trick".

How do I ?