Still having problems with order of rows after grouping

Posted by: hpd71 on 8 September 2017, 1:05 pm EST

  • Posted 8 September 2017, 1:05 pm EST


    I am still having some issues with the order of rows after grouping. This is a major problem for me, as it is critical that the row order is maintained after the grouping is done.

    I have attached a few screen shots so that you can see the issue. The first screen shows the grid in use with no grouping applied. The last six rows are unbound rows that are added after the grid is bound to a dataset.

    The column that is grouped on is actually hidden, and for the bound rows, the data is in the dataset. For the unbound rows there is no value in the hidden column. It was suggested that I put a space into the unbound rows in the column that is grouped which should leave the order to be the same. As you can see from the last screen shoot. This only moved the group to the top of the sheet (when it needs to stay at the bottom) and the order was still changed.

    I really need to group the data, and have the order of the 6 rows at the bottom, not have their order changed. The order that is applied seems to make no sense. It’s not alpha, or any other order i can see.

    Another interesting thing, is that one of the totals in the last 6 rows is a % value, yet after the grouping the formating for % is somehow gone. 



  • Replied 8 September 2017, 1:05 pm EST


    There is nothing you can do to sort the null values in the same order everytime. If there was a way you would have to implement a IComparer interface to compare the objects. Here is code that basically handles a the compare like the default. If you can find code to sort the null values in the same order, you would replace it in this code.

    	Private Sub FpSpread1_Grouping(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.GroupingEventArgs) Handles FpSpread1.Grouping
    e.GroupComparer = New myComparer
    End Sub
    End Class

    Public Class
    Implements IComparer

    Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
    x Is Nothing And Not y Is Nothing Then
    End If
    If Not
    x Is Nothing And y Is Nothing Then
    End If
    x Is Nothing And y Is Nothing Then
    End If
    x > y Then Return 1
    If x < y Then Return -1
    If x = y Then Return 0
    End Function
    End Class
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels