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

    <SPAN><FONT face=Calibri>Hi,</FONT></SPAN>


    <SPAN><o:p><FONT face=Calibri></FONT></o:p></SPAN>


    <SPAN><FONT face=Calibri>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.</FONT></SPAN>


    <SPAN><FONT face=Calibri>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.</FONT></SPAN>


    <SPAN><FONT face=Calibri>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.</FONT></SPAN>


    <SPAN><FONT face=Calibri>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.</FONT></SPAN>


    <SPAN><o:p><FONT face=Calibri>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. </FONT></o:p></SPAN>


    <SPAN><o:p><FONT face=Calibri> </FONT></o:p></SPAN>


    <SPAN><o:p><FONT face=Calibri> </FONT></o:p></SPAN>


    2008/03/groupingissue.zip
  • Replied 8 September 2017, 1:05 pm EST

    Hello,


    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.

     <PRE class=coloredcode> <SPAN class=kwd>Private Sub</SPAN> FpSpread1_Grouping(<SPAN class=kwd>ByVal</SPAN> sender <SPAN class=kwd>As Object</SPAN>, <SPAN class=kwd>ByVal</SPAN> e <SPAN class=kwd>As</SPAN> FarPoint.Win.Spread.GroupingEventArgs) <SPAN class=kwd>Handles</SPAN> FpSpread1.Grouping
    e.GroupComparer = <SPAN class=kwd>New</SPAN> myComparer
    <SPAN class=kwd>End Sub
    End Class

    Public Class</SPAN> myComparer
    <SPAN class=kwd>Implements</SPAN> IComparer

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

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

Learn More

Forum Channels