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
670
How to sort by number of items in groupby row?
posted

Hi folks

I have a grid and I want to sort the grid by the number of items in groupby row (descending). Any idea how to do that? (I want the row with maximum number of items at top, ...)

 

Parents
No Data
Reply
  • 670
    Verified Answer
    posted

    Here is how I did it. Mike thanks for the pointer :)

        Private Class DescendingGroupByRowsSorter

            Implements IComparer

     

            Private Function Compare(ByVal xObj As Object, ByVal yObj As Object) As Integer Implements IComparer.Compare

                Dim x As UltraGridGroupByRow = DirectCast(xObj, UltraGridGroupByRow)

                Dim y As UltraGridGroupByRow = DirectCast(yObj, UltraGridGroupByRow)

     

                ' Compare the group rows by the number of items they contain.

                Return y.Rows.Count.CompareTo(x.Rows.Count)

            End Function

     

        End Class

     

     

        Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout

           

            For Each ugc As UltraGridColumn In Me.UltraGrid1.DisplayLayout.Bands(0).Columns

                ugc.GroupByComparer = New DescendingGroupByRowsSorter

            Next

        End Sub

Children