What is the equivalent of SortMemberPath in SFDataGrid
I am looking for an alternate of SortMemberPath in SFDataGrid.
Could you share the name with an example ASAP?
Best Regards,
Qasim
SIGN IN To post a reply.
3 Replies
FP
Farjana Parveen Ayubb
Syncfusion Team
August 27, 2019 11:21 AM UTC
Hi Qasim,
Thank you for using Syncfusion controls.
You can able to achieve the SortMemberPath behavior in SfDataGrid by using custom sorting support.
Please refer the below code example
[Xaml]
|
<syncfusion:SfDataGrid.SortComparers>
<Linq:SortComparer Comparer="{StaticResource Comparer}" PropertyName="ShipCity" />
</syncfusion:SfDataGrid.SortComparers> |
[C#]
|
public class CustomerInfo : IComparer<Object>, ISortDirection
{
public int Compare(object x, object y)
{
int namX;
int namY;
if (x.GetType() == typeof(Orders))
{
namX = ((Orders)x).OrderID;
namY = ((Orders)y).OrderID;
}
else if (x.GetType() == typeof(Group))
{
namX = ((Group)x).Key.ToString().Length;
namY = ((Group)y).Key.ToString().Length;
}
else
{
namX = x.ToString().Length;
namY = y.ToString().Length;
}
if (namX.CompareTo(namY) > 0)
return SortDirection == ListSortDirection.Ascending ? 1 : -1;
else if (namX.CompareTo(namY) == -1)
return SortDirection == ListSortDirection.Ascending ? -1 : 1;
else
return 0;
}
private ListSortDirection _SortDirection;
public ListSortDirection SortDirection
{
get { return _SortDirection; }
set { _SortDirection = value; }
}
} |
Sample Location: https://www.syncfusion.com/downloads/support/forum/146936/ze/CustomSorting-1905361320
UG link: https://help.syncfusion.com/wpf/datagrid/sorting?cs-save-lang=1&cs-lang=csharp#custom-sorting
Please let us know if you need any further details on this.
Regards,
Farjana Parveen A
TH
Thymopathy
August 30, 2019 07:31 AM UTC
That's an useful info.
SS
Susmitha Sundar
Syncfusion Team
September 2, 2019 10:04 AM UTC
Hi Thymopathy,
Thanks for the update.
Please get back to us if you require further assistance from us.
Regards,
Susmitha S
SIGN IN To post a reply.
- 3 Replies
- 4 Participants
-
QR Qasim Raza
- Aug 26, 2019 11:28 AM UTC
- Sep 2, 2019 10:04 AM UTC