Posted 31 March 2020, 12:51 pm EST
Can you please provide an example of using C1CollectionView.CustomSort? A short code fragment will do. It’s not apparent to me what you expect us to provide on this interface. I’ve tried passing a custom IComparer implementation without success.
Thank you,
John
public class SortAcendingProjectStructureID : IComparer
{
int IComparer.Compare(object a, object b)
{
ProjectViewModel p1 = (ProjectViewModel)a;
ProjectViewModel p2 = (ProjectViewModel)b;
return ((new CaseInsensitiveComparer()).Compare(p1.Site.StructureId, p2.Site.StructureId));
}
}
// Class to do descending sort on StructureID property
public class SortDescendingProjectStructureID : IComparer
{
int IComparer.Compare(object a, object b)
{
ProjectViewModel p1 = (ProjectViewModel)a;
ProjectViewModel p2 = (ProjectViewModel)b;
return ((new CaseInsensitiveComparer()).Compare(p2.Site.StructureId, p1.Site.StructureId));
}
}
SortDescription sortDescr = _CollectionView.SortDescriptions[0];
if (sortDescr.Direction == ListSortDirection.Ascending)
_CollectionView.CustomSort = new ProjectViewModel.SortAcendingProjectStructureID();
else
_CollectionView.CustomSort = new ProjectViewModel.SortDescendingProjectStructureID();