Filters with accents DataTables 2.0
Filters with accents DataTables 2.0
Hi,
In my project, I'm migrating to DataTables 2.0. I have a table with a filter on a column. The values are QF vérifié, QF à vérifier, QF à vérifier en priorité and QF non requis.
In my previous version, I used this event at the modification of a filter:
.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
});
It was not working with the accents in DataTables 2.0 (QF non requis worked fine) so I looked in the documentation and replaced it by:
.on('change', function () {
var val = $(this).val();
column
.search( val , {
caseInsensitive: false,
exact: true,
})
.draw();
});
This solution is not working with the characters "à" and "é". If I replace them with "a" and "e", everything is working perfectly. What can I do to use these special characters? I tried to use RegExp objects, with no results.
This question has accepted answers - jump to:
Answers
I fear you've found a bug in DataTables 2 here - sorry about that. I tried to be a bit clever with the accented characters by allowing them to be searched either with or without the accent, but that messes up the exact matching.
Let me have a little think about this and get back to you!
Allan
I've committed a fix that I believe is the correct way to address this issue. You can see it in action here. The fix will be in the 2.0.1 release.
Regards,
Allan