2

How can I set a custom filter in my code to ignore accents and special character from the table before filtering?

I am using DataTables plugin (http://www.datatables.net/)

1 Answer 1

6

Include a version of the data that is missing the accents as a column in the datatable. You hide that column by adding an entry in the aoColumns array in the configuration literal.

Let's say you start with 4 columns. One of these has accents. Add a fifth column with non-accented data, and add a configuration literal with { "bVisible": false } so that it will not be displayed.

It's invisible, but it's still searchable / filterable:

$(document).ready(function() {
    $('#example').dataTable( {
        "aoColumns": [ 
            null,
            null,
            null,
            null,
            { "bVisible": false }
        ] } );
});

See the column documentation for more on configuration. DataTables with hidden columns is an example in use.

Sign up to request clarification or add additional context in comments.

2 Comments

Using this, I have to set the number of columns manualy, right? Doesn't exists a way to hide a column without especify the number of columns?
Right, each of those null's represents no extra configuration. In my experience with using ajax and DataTables, the number of columns needs to match the number of entries in aoColumns

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.