Reputation: 610
I want to search in columns with accent neutralise plugin, but it didnt work at all. It transform searched text to accentless, but it doesnt match the results. I want to search Kollar and with result Kollár.
Example:
Here is the code:
var table = jQuery('#example').DataTable();
jQuery.fn.DataTable.ext.type.search.string = function ( data ) {
return ! data ?
'' :
typeof data === 'string' ?
data
.replace( /έ/g, 'ε')
.replace( /ύ/g, 'υ')
.replace( /ό/g, 'ο')
.replace( /ώ/g, 'ω')
.replace( /ά/g, 'α')
.replace( /ί/g, 'ι')
.replace( /ή/g, 'η')
.replace( /\n/g, ' ' )
.replace( /á/g, 'a' )
.replace( /é/g, 'e' )
.replace( /í/g, 'i' )
.replace( /ó/g, 'o' )
.replace( /ú/g, 'u' )
.replace( /ê/g, 'e' )
.replace( /î/g, 'i' )
.replace( /ô/g, 'o' )
.replace( /è/g, 'e' )
.replace( /ï/g, 'i' )
.replace( /ü/g, 'u' )
.replace( /ã/g, 'a' )
.replace( /õ/g, 'o' )
.replace( /ç/g, 'c' )
.replace( /ì/g, 'i' ) :
data;
};
table.columns().eq( 0 ).each( function ( colIdx ) {
jQuery( 'input', table.column( colIdx ).header() ).on( 'keyup change', function () {
table
.column( colIdx )
.search(
jQuery.fn.DataTable.ext.type.search.string( this.value )
)
.draw();
});
});
EDIT: Its not a duplicate of jQuery DataTables - Accent-Insensitive Alphabetization and Searching becouse I need it to column searching not for global search. Ive already read it and it doesnt works for me.
Upvotes: 2
Views: 1378
Reputation: 610
The problem was in the table. It contains empty (only white space) cells and in this case whole table didnt filter with accent neutralise function. So I change white space to
and it works like a charm :). It cost me lot of time to find it out :).
Upvotes: 2