Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort datatable alphabitecal and case insensitive using jQuery?

I am using jquery datatable. It display list of user.(first name, last name, etc). Is it possible to set so that capital letter always comes before small letter when I click on ascending order of last name.(Case sensitive)

Following is example

FirstName   LastName
A             Xb   <--X is Captial-->
B             xa   <-- x is small-->
c             yc

When I click on sorting on last name with ascending order it will display following

 FirstName   LastName

B             xa   <--small-->
A             Xb   <--X is Captial-->
c             yc

Is it any property available which sort in case sensitive?

like image 555
Raje Avatar asked Nov 12 '22 16:11

Raje


1 Answers

This solved my problem:

'columnDefs': [

 'targets': 0,      
 'render': function(data, type, row, meta){                                                     
  return type === "sort" ? data.toLowerCase() : data;

}]
like image 120
Mevlüt Beder Avatar answered Nov 15 '22 07:11

Mevlüt Beder