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, ...)
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.
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
Here is how I did it. Mike, thanks for the pointer ;)
DescendingGroupByRowsSorter
IComparer
IComparer.Compare
(xObj, UltraGridGroupByRow)
(yObj, UltraGridGroupByRow)
y.Rows.Count.CompareTo(x.Rows.Count)
Function
Class
UltraGrid1.InitializeLayout
.UltraGrid1.DisplayLayout.Bands(0).Columns
ugc.GroupByComparer =
Sub
Ok, I've found this
http://help.infragistics.com/Help/NetAdvantage/WinForms/2010.3/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v10.3~Infragistics.Win.UltraWinGrid.UltraGridColumn~GroupByComparer.html
Do I have to do it column by column or is there a global way of doing this?
Hi Mike
Thanks for your answer but can you provide a quick sample?