Version 16.3.0.21 - My project is Android only right now, so I'm not sure if this is affecting other platforms.
I have both GroupDescriptors and SortDescriptors added to my SfListView. When an item is added, the GroupDescriptor is called, and items are grouped appropriately, but the SortDescriptor comparers are not so items are not sorted within the groups. I've also tried to RefreshView after item added, but that didn't seem to help. When the list is loaded, and descriptors added, it does group and sort correctly. Has anyone else run into this?
Any help will be greatly appreciated.
Sample code to implement issue:
this.clientListView.DataSource.GroupDescriptors.Add(new Syncfusion.DataSource.GroupDescriptor
{
PropertyName = "FirstName",
KeySelector = (object obj1) =>
{
var item = (obj1 as Client);
return item.FirstName[0].ToString().ToUpper();
}
});
this.clientListView.DataSource.SortComparer = new CustomComparer();
this.clientListView.DataSource.SortDescriptors.Add(new Syncfusion.DataSource.SortDescriptor
{
PropertyName = "FirstName",
Direction = Syncfusion.DataSource.ListSortDirection.Ascending,
Comparer = new CustomComparer()
});
public class CustomComparer : IComparer<object>, ISortDirection
{
public int Compare(object x, object y)
{
string nameX;
string nameY;
//For Contacts Type data
if (x.GetType() == typeof(Client))
{
//Calculating the length of ContactName if the object type is Contacts
nameX = ((Client)x).FirstName;
nameY = ((Client)y).FirstName;
}
else
{
nameX = x.ToString();
nameY = y.ToString();
}
// Objects are compared and return the SortDirection
if (string.Compare(nameX, nameY, true) > 0)
return SortDirection == ListSortDirection.Ascending ? 1 : -1;
else if (string.Compare(nameX, nameY, true) == -1)
return SortDirection == ListSortDirection.Ascending ? -1 : 1;
else
return 0;
}