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, ...)
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
The GroupbyComparer property is on the column, so you have to set the property on each column. But you can re-use the same instance of your DescendingGroupByRowsSorter for every column - you do not need to create a new one on each column.