Issue because of inter group sorting.

Hi,

I have a Table containing Streetnames, User-Numbers and House Numbers.
I would like to group it by Streetname and order by User-Numbers.
The result should look like this:

Mainstreet
User 1 - No 1
User 2 - No 2
User 3 - No 3
Elmstreet
User 4 - No 2
User 5 - No 5
User 6 - No 8

Unfortunately the result looks like this (because of inter group sorting - re-sorting only affects the inner rows):

Elmstreet
User 4 - No 2
User 5 - No 5
User 6 - No 8
Mainstreet
User 1 - No 1
User 2 - No 2
User 3 - No 3

Is this generally possible with TAdvStringGrid and the grouping feature?
If not: is there a better way to highlight the street rows?

Thank you and regards.

Do you call  grid.QSortGroup with grid.SortSettings.Column set to the column of the user-numbers?
QSortGroup performs a sorting within groups only.

The list is sorted by the sql query.
After adding the content to the cells, i call
GroupColumn := 1;

QSortGroup does not affect the table after GroupColumn. Or do i made a mistake?

Do you set the desired column to perform sort on and sort direction via grid.SortSettings.Column / grid.SortSettings.Direction before you call grid.QSortGroup?

Yes, i set the column via SortSettings.Column.

By the way, this is how the result should look like:


(https://picload.org/image/wdlccpc/table.png)
I don't think that it's possible to do this with QSortGroup, or am i wrong?

I cannot see a problem here.

Sample code applied to a default TAdvStringGrid:

begin
 advstringgrid1.RowCount := 50;
 advstringgrid1.RandomFill(false,10);
 advstringgrid1.Group(1);

 advstringgrid1.SortSettings.Column := 1;
 advstringgrid1.SortSettings.Direction := sdAscending;
 advstringgrid1.QSortGroup;
end;

This performs grouping first and then does an ascending sort, per group, on column 1.

The sorting for this table is correct.

But in another case, it's not:


https://picload.org/image/wdcopro/table2.png

I fail to see what is incorrect about the sorting in your screenshot. All 3 groups have within the groups a correct sorting on LfdNr.

So, please explain what exactly you see being incorrect?

I like to have a ascending numbering over all grouping, like this:

Zeppelinstr. 17
1
2
3
...

Wirtembergstr. 137
12
13
14
...

Wirtembergstr. 139
18
19
20
...

The primary sort is on the grouping column, i.e. W is before Z so will always be shown first.

Ok, thank you.