You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
David Konrad made a plugin that solves the diacritics problem in Datatables, and quoting him directly:
When filtering or sorting a table with accented characters (letters with diacritical marks) it can be frustrating to have an input such as Zurich not match Zürich in the table (u !== ü).
So I used some of his code for solving this problem.
This is the code I added at the top of the JS file:
And later I use it in two places. One is in the async search(query) {} function, just after this.table.dataRows.forEach(function (row) { row.visible = false;:
And after hasMatch = cells.some(function (cell, idx) {:
var cellWithoutDiacritics = removeDiacritics(cell.getTextContent());
if (cellWithoutDiacritics.toLowerCase().indexOf(word) >= 0) {
return true;
}
So the filtering is fixed.
The other part is the sort function sort(column, direction, initial = false) {} right after declaring the ca and the cb variables, add this code:
ca = removeDiacritics(ca);
cb = removeDiacritics(cb);
And that's all.
Now if I have a table with spanish provinces, I can search and sort Ávila, or Castilla y León, and those accents are ignored, and the filtering ans sorting is done in the right way, no matter if I write AV or ÁV (with the accent):
Thank you very much in advance, and I hope this helps.
The text was updated successfully, but these errors were encountered:
Probably a extension, but I hardcoded it because I don't understand very well how to make a plugin for it.
Thank you for your reply, and thanks for this library, is amazing!
David Konrad made a plugin that solves the diacritics problem in Datatables, and quoting him directly:
So I used some of his code for solving this problem.
This is the code I added at the top of the JS file:
And later I use it in two places. One is in the
async search(query) {}
function, just afterthis.table.dataRows.forEach(function (row) { row.visible = false;
:And after
hasMatch = cells.some(function (cell, idx) {
:So the filtering is fixed.
The other part is the sort function
sort(column, direction, initial = false) {}
right after declaring the ca and the cb variables, add this code:And that's all.
Now if I have a table with spanish provinces, I can search and sort Ávila, or Castilla y León, and those accents are ignored, and the filtering ans sorting is done in the right way, no matter if I write AV or ÁV (with the accent):
Thank you very much in advance, and I hope this helps.
The text was updated successfully, but these errors were encountered: