Amadeu Cabanilles Amadeu Cabanilles - 1 month ago 10
jQuery Question

DataTables - Not case-sensitive ordering

I have this datatable definition

$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
var table = $('#producersTableId').DataTable({
"dom": '<"top">rt<"bottom"lp><"clear">',
"autoWidth": false,
"order": [[1, 'asc']],
"columnDefs": [
{"targets": [0], "width": '25%'},
{"targets": [1], "width": '40%'},
{className: "dt-body-center" , "targets": [2], "width": '5%'},
{className: "dt-body-center" , "targets": [3], "width": '30%'},
]
});
table.columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
});


Is there a way in the
"order": [[1, 'asc']],
option to ignore case in the order (Not case-sensitive ordering) ?

Answer

Please see https://datatables.net/forums/discussion/38495 and http://live.datatables.net/qobihina/1/edit. The code is from an example on

Please see https://datatables.net/forums/discussion/38495 and http://live.datatables.net/qobihina/1/edit. The code is from an example on 

/* JAVASCRIPT */
$(document).ready( function () { var table = $('#example').DataTable(); } );

/* HTML */
<table id="example" class="display nowrap" width="100%">
    <thead> 
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
         </tr>
    </thead>
    <tfoot>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </tfoot>
    <tbody>
        <tr>
            <td>b</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$3,120</td>
        </tr>
        <tr>
            <td>B</td>
            <td>Director</td>
            <td>Edinburgh</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$5,300</td>
        </tr>
        <tr>
            <td>A</td>
            <td>Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$4,800</td>
        </tr>
        <tr>
            <td>a</td>
            <td>Javascript Developer</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2012/03/29</td>
            <td>$3,600</td>
        </tr>
    </tbody>
</table>