Grouping problem


07-08-2009, 2:01 PM
I'm having a problem with grouping on sharpgrid version 1129. If there is no sortorder defined on a column before you drag to create a group, the group in messed up

put this in the form_load with a sharpgrid control and drag the first column to group it. you will see two "apple" heading rows (see attachment)
CODE 1:
sg.ColumnClickSort = True
sg.Rows.RemoveAll False
sg.Rows.Add sgFormatCharSeparatedValue, "apple,banana,orange"
sg.Rows.Add sgFormatCharSeparatedValue, "apple,pear,grape"
sg.Rows.Add sgFormatCharSeparatedValue, "apple,plum,kiwi"
sg.Rows.Add sgFormatCharSeparatedValue, "grapefruit,nectarine,berry"
sg.Rows.Add sgFormatCharSeparatedValue, "apple,guava,cherry"
Note: If you click the group header to sort, it groups properly


If the column is already sorted, or if you add a group through code and specify sorting, it works fine:
CODE 2:
sg.ColumnClickSort = True
sg.Rows.RemoveAll False
sg.Rows.Add sgFormatCharSeparatedValue, "apple,banana,orange"
sg.Rows.Add sgFormatCharSeparatedValue, "apple,pear,grape"
sg.Rows.Add sgFormatCharSeparatedValue, "apple,plum,kiwi"
sg.Rows.Add sgFormatCharSeparatedValue, "grapefruit,nectarine,berry"
sg.Rows.Add sgFormatCharSeparatedValue, "apple,guava,cherry"
sg.Groups.Add sg.Columns(1).ColIndex, sgSortAscending, sgSortTypeDefault


One workaround I found was to add some code to the
BeforeGroupChange() event
Private Sub sg_BeforeGroupChange(...)
    If Operation = sgGroupAdd Then
        If SortOrder = sgNoSorting Then
            SortOrder = sgSortAscending
        End If
    End If
End Sub

Is there another solution or option I am missing? I think the other version of the control automatically sorted when grouped.


Re: Grouping problem


07-08-2009, 8:58 PM
QWERTY1,

You are right. The workaround here is to apply sorting in BeforeGroupChange event.
We have Case 27139 about this problem you've described addressed to our
development staff and it is currently fixed in interim build. If you would like to get this build please contact us via e-mail sharpgrid.support@grapecity.us.com with your SharpGrid serial number.

Thank you,
Andrey T.