Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Sort rows, move rows with an empty value to the end
posted

 Situation:

    I have a grid with columns "NAME" and "DATE". When sorting (ascending) on date, all rows without a date should be placed at the end of the rowcollection (like when sorting descending).

    This is what i'm currently doing:

    Private Sub gridcandidates_AfterSortChange(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.BandEventArgs) Handles gridcandidates.AfterSortChange

        Dim col As UltraGridColumn = e.Band.Columns("DATE")
        If col.SortIndicator = SortIndicator.Ascending Then
            For i As Integer = gridcandidates.Rows.Count - 1 To 0 Step -1
            If Not IsDBNull(gridcandidates.Rows(i).Cells("DATE").Value) Then
                gridcandidates.Rows.Move(gridcandidates.Rows(i), 0) 'Move row to beginning
            Else
                gridcandidates.Rows.Move(gridcandidates.Rows(i), gridcandidates.Rows.Count - 1) 'Move row to end
            End If
        Next
        End If

    End Sub

 

Question/problems:

    - It messes up the sort... the columns aren't sorted by date.

    - Is there anyway to improve the code? I'm sure i'm overlooking something!

Parents Reply Children
No Data