I have the following table structure:
Department
Province
district
Person
Sequence Province
District Sequence
Lima
Province 1
DistritoB
Juan Perez
1
Jose Manuel
Dario Gomez
Maria Guevara
Piura
Talara
2
Susana Ramirez
Tito Juan
Alberto Sosa
Arequipa
DistritoA
3
I want to be grouped by Department, Province, district,now the database and return the list sorted by province and Sequence Sequence District mean that I want to order by a field that is not the field to group, since the control automatically brings me and that I do not want, I seen some post and they all say use: IComparer,something like this: e.Layout.Bands (0). Columns ("SecuenciaProvincia). GroupByComparer = New MySortComparer ()But I get, I hope I can help, I need to order by two fields Sequence Sequence Province and District and while group by Department, Province, district, but which respects the order of the fields arriving from the sequence database ,
Private Sub dgArbol_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles dgArbol.InitializeLayout
e.Layout.Bands(0).SortedColumns.Add("Departament", False, True)e.Layout.Bands(0).SortedColumns.Add("Province", False, True)e.Layout.Bands(0).SortedColumns.Add("District", False, True)???????????????????????????
e.Layout.Bands(0).Columns("SecuenceProvince").GroupByComparer = New MySortComparer()
e.Layout.Bands(0).Columns("SecuenceDistrict").GroupByComparer = New MySortComparer()
???????????????????????????
End
Sub
Thank you.It is very urgent
Hi,
The IComparable interface has only one method, Compare. This method passes you two objects and you decide which one is less than the other for purposes of sorting. In the case of a GroupByComparer, the two objects will each be an UltraGridGroupByRow.
I'm not really clear on what you are trying to do here. Your post is a bit jumbled. Which level of the grouping are you trying to sort?
It sounds like you want to sort the Districts by the DistrictSequence and the Provinces by the ProvinceSequence. In that case, you need to create two different classes that each implement IComparer. For example, you would create an IComparer class for the District column. This comparer would get two GroupByRows into into Compare method. The GroupByRow has a value, which will return the District, and from there you have to determine the Sequence. It seems a little odd that the sequence numbers are in the same table and the Districts, because that opens up the possibility that the same District could have two different Sequence values. But assuming they are always the same, you could just get the first child row from the GroupByRow and use the DistrictSequence from that row. Then do the same thing for the second GroupByRow and compare the two numbers.
Hello Mike.Yesterday I resolved my problem the same way your asking me this,Just thank you for your great support.Sincerely,