key problems with accent (spanish)
key problems with accent (spanish)
nestoronald
Posts: 5Questions: 0Answers: 0
Hello, I have problems with accented words filter. Example: I have a table with data:
1. Juan Perez
2. Jose Pérez
3. Pedro Pèrez.
Write "Perez" and I only filter: 1. Juan Perez. I want to filter all the "Perez" with or without accent.
1. Juan Perez
2. Jose Pérez
3. Pedro Pèrez.
Write "Perez" and I only filter: 1. Juan Perez. I want to filter all the "Perez" with or without accent.
This discussion has been closed.
Replies
Here is an example of how you could modify the built-in search string formatter in 1.10 to remove the accents and filter only on non-accented characters.
[code]
$.fn.DataTable.ext.type.search.string = function ( data ) {
return ! data ?
'' :
typeof data === 'string' ?
data
.replace( /\n/g, " " )
.replace( /é/g, 'e' )
.replace( /ê/g, 'e' )
.replace( /è/g, 'e' ) :
data;
}
[/code]
1.10 is pre-beta, but it is available as the nightly on http://datatables.net/download .
Let me know how you get on with it!
Allan
$.fn.DataTable.ext.type.search.string = function ( data ) {
return ! data ?
'' :
typeof data === 'string' ?
data
.replace( /\n/g, " " )
.replace( /[éêè]/g, 'e' ) :
data;
}
[/code]
would be more efficient thinking about it. Obviously the other accented characters would need to be added as well.
Allan
Allan
http://immense-journey-5655.herokuapp.com/
Help please.
Allan
Allan