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

Disable Case Sensitive sorting

Hi,

My example has the grid grouping control populated with customer details(CustomerId, FirstName, FamilyName, Phone, Email).
If i try to sort the grid by FamilyName and FirstName, i get the result as a case sensitive sort as below

CustomerId FirstName FamilyName Phone Email
4 Alex Brown 4541234 qwq@ww.com
1 Brian Brown 3423232 wwe@wewe.com
3 Amber BROWN 4345656 tyty@tyt.ac.df
2Asmin
BROWN4587527tytryt@rtr.cvcb

Expected Result
CustomerIdFirstNameFamilyNamePhoneEmail
4AlexBrown4541234qwq@ww.com
2Amber
BROWN
4345656
tyty@tyt.ac.df
3Asmin
BROWN
4587527
tytryt@rtr.cvcb
1Brian
Brown3423232
wwe@yhu.com

How can i disable the case sensitive sort. Any help is highly appreciated.

Thanks

1 Reply

AR Arulpriya Ramalingam Syncfusion Team August 11, 2017 01:43 PM UTC

Hi Meetu, 
 
Thanks for using Syncfusion products. 
 
In order to sort the records with case insensitive, the CustomSortComparer can be implemented from IComparer interface and the Compare() method can be customized to sort the records with case insensitive. The TableControlCellClick event can be used to add the CustomSortComparer at run time. We have modified the sample as per your requirement. Please make use of below code and sample, 
 
Code snippet 
 
SortColumnDescriptor cd; 
#region CustomSort 
public class CustomSortComparer : IComparer 
{ 
    public CustomSort() 
    { 
    } 
    public int Compare(object x, object y) 
    { 
        if (x == null && y == null) 
        { 
            return 0; 
        } 
        else 
        { 
            //To avoid the Case sensitive 
            return ((IComparable)x.ToString().ToLower()).CompareTo(y.ToString().ToLower()); 
        } 
    } 
} 
#endregion 
 
 
 
Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon