We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

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

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; } 
    } 
} 
 
 
 
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   


Loader.
Live Chat Icon For mobile
Up arrow icon