DataTables Accent neutralise
HTML
<link rel="stylesheet" href="https://cdn.datatables.net/v/dt/jq-3.6.0/dt-1.12.1/datatables.min.css">
<script src="https://cdn.datatables.net/v/dt/jq-3.6.0/dt-1.12.1/datatables.min.js"></script>
<table id="table_id" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td data-order="B">New York</td>
<td data-order="2">Test1</td>
</tr>
<tr>
<td data-order="A">ZĂĽrich</td>
<td data-order="1">Test2</td>
</tr>
</tbody>
</table>
JavaScript
(function(){
function removeAccents ( data ) {
if ( data.normalize ) {
// Use I18n API if avaiable to split characters and accents, then remove
// the accents wholesale. Note that we use the original data as well as
// the new to allow for searching of either form.
return data +' '+ data
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '');
}
return data;
}
var searchType = jQuery.fn.DataTable.ext.type.search;
console.log(searchType)
searchType.string = function ( data ) {
console.log(data)
return ! data ?
'' :
typeof data === 'string' ?
removeAccents( data ) :
data;
};
searchType.html = function ( data ) {
return ! data ?
'' :
typeof data === 'string' ?
removeAccents( data.replace( /<.*?>/g, '' ) ) :
data;
};
}());
$(document).ready( function () {
$('#table_id').DataTable();
} );