JavaScript jQuery DataTables not working special characters results in search jquery datatable not working,jquery datatables responsive not working

I am trying to search some words with special characters in jQuery Datatables plugin.

There are some results in datatable like this:

Peinado, Alma_María
Aguilar Castillo, Antonio José

When I try to search "alma_maría", the first result is shown:

Peinado, Alma_María

When I try "alma_maria" (note that I am using character "i" instead "í"), nothing is shown.

Screenshot 1:

Trying to search "alma_maría"

Screenshot 2:

Trying to search "alma_maria"

Is there any way to configure Datatables to show special characters results when I search without special characters?

My HTML/Javascript code:

<table class="display table table-bordered table-striped" id="table-colegiados">
<thead>
<tr>
    <th>{$TXT.nombre}</th>
    <th>{$TXT.ciudad}</th>
    <th>{$TXT.email}</th>
    <th>{$TXT.telefono}</th>
    <th>{$TXT.dni}</th>
    <th>{$TXT.colegiado}</th>
    <th>{$TXT.asesor}</th>
    <th>{$TXT.editar}</th>
    <th>{$TXT.borrar}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>

<script type="text/javascript">
    $.fn.dataTableExt.oApi.fnGetFilteredNodes = function ( oSettings )
    {
        var anRows = [];
        for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ ) {
            var nRow = oSettings.aoData[ oSettings.aiDisplay[i] ].nTr;
            anRows.push( nRow );
        }
        return anRows;
    };
    $.fn.dataTableExt.afnFiltering.push(function(oSettings, aData, iDataIndex) {
        if ( oSettings.nTable == document.getElementById( 'table-colegiados' )){
            var asesor = aData[6];
            var checked = $('#checkbox_asesores').is(':checked');
            if (checked) {
                if (asesor == '1') {
                    return true;
                }
            } else {
                return true;
            }
            return false;
        } else {
            return true;
        }
    });
    var oTable = $('#table-colegiados').dataTable({
            "aaSorting": [ [0,'asc'] ],
            'iDisplayLength': 25,
            "bProcessing": true,
            "bServerSide": false,
            "bDeferRender": true,
            "sAjaxSource": "ajax/getColegiados.php",
            "fnServerData": function ( sSource, aoData, fnCallback ) {
                $.getJSON( sSource, aoData, function (json) {
                    fnCallback(json)
                } );
            }
    });
    $('#checkbox_asesores').on("click", function(e) {
        oTable.fnDraw();
    });
</script>
Answer:1

The answer is Accent neutralisation. and there is ready plugin for it.

http://www.datatables.net/plug-ins/filtering/type-based/accent-neutralise

$.fn.dataTableExt.ofnSearch['string'] = function ( data ) {
return ! data ?
    '' :
    typeof data === 'string' ?
        data
            .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, 'c' ) :
        data;
};

Demo : http://jsfiddle.net/kishoresahas/416mvzws/

Answer:2

I'm trying to use a recursive function to get the last key value form a simple json using javascript I have this json: { 'a': { 'b': { 'c': 12, 'd': 'Hello World' }, 'e': [...

I'm trying to use a recursive function to get the last key value form a simple json using javascript I have this json: { 'a': { 'b': { 'c': 12, 'd': 'Hello World' }, 'e': [...

  1. json object each
  2. json object each jquery
  3. json object each loop

I have looked through several threads/resources and can't seem to get working tooltips. Here is the code: nv.addGraph(function() { self.chart = nv.models.multiBarChart() ....

I have looked through several threads/resources and can't seem to get working tooltips. Here is the code: nv.addGraph(function() { self.chart = nv.models.multiBarChart() ....

Here is the Javascript: var bubbles = $('.history .bubble'); bubbles[bubbles.length-1].after('<div class="bubble me">' + text + '</div>'); Here is the HTML: Any idea why anything I ...

Here is the Javascript: var bubbles = $('.history .bubble'); bubbles[bubbles.length-1].after('<div class="bubble me">' + text + '</div>'); Here is the HTML: Any idea why anything I ...

I'm working on a website about donation using Gatsby v2 (Reactjs) and I need an example like open modal window on button donation click using Gatsby or ReactJS. I search on internet and I got nothing. ...

I'm working on a website about donation using Gatsby v2 (Reactjs) and I need an example like open modal window on button donation click using Gatsby or ReactJS. I search on internet and I got nothing. ...