Comments (8)
Thanks! Yes, I'll look into this. Having some form of diacritic support built into DataTables is something I want to add, so I'll look into this when I do that. Can't be certain when that will be though...
from plugins.
Thank you for the test case! The fix is fairly straight forward - we need to tell DataTables to use localeCompare
rather than straight character number sorting. That can be done with the new DataTable.type()
method:
DataTable.type('string', 'order', {
asc: function (a, b) {
return a.localeCompare(b);
},
desc: function (a, b) {
return b.localeCompare(a);
}
});
Example here: https://live.datatables.net/dayodoli/3/edit .
You'd need to do similar for html
data type as well if you needed that.
Should DataTables do that by default? Very possibly. I didn't include it a while back because of the impact on performance. That might have changed with updates to the Javascript engines. I'll look into it again.
edited Fix from below.
from plugins.
The same applies for sorting plugin - if diacritics sort plugin is used, it only works fro string columns. If column contains any HTML data, diacritics sorting doesn't work.
from plugins.
DataTables 2 effectively has this ability built in. This plug-in is no longer useful. If you are having problems with that ability, please link to a test case showing the issue.
from plugins.
Yes, DT 2.0 has diacritics filtering built-in, and it works perfectly! Unfortunately, that doesn't apply to sorting, so I still have to use this plugin - https://datatables.net/plug-ins/sorting/diacritics-sort. Unfortunately, plugin doesn't work if column contains HTML data.
Here's an example using DT2 - https://live.datatables.net/dayodoli/1/edit
See "Name" column, which contains names with diacritics. In default state, names are sorted alphabetically. However, when names get sorted alphabetically by DT, sorting is wrong because DT orders names without diacritics first, and moves names with diacritics to the bottom.
If I add sorting plugin, it works as long as column with names doesn't have any HTML tags. Once HTML is added to some rows, ordering doesn't work again.
from plugins.
Thanks for the example. I just want to let you know that code for desc contains a small typo and should be return b.localeCompare(a);
(otherwise sorting descending will change nothing and items will be sorted ascending)
from plugins.
Doh - good point! I've updated my post in case anyone else gets caught by that.
from plugins.
By the way, I'm not sure if you are aware that adding data-order
tag prevents diacritics filter from working. See example here - https://live.datatables.net/dayodoli/4/edit - I just added data-order
attribute to names, and diacritics filter doesn't work. In fact, even if you enter whole name correctly (with or without diacritics) into search field, DT2 can't find it.
I use a workaround now: add some random string to data-order
attribute. For example, if I change data-order="1"
to data-order="random-1"
, filtering starts working again.
from plugins.
Related Issues (20)
- i18n: inconsistent naming of files HOT 3
- Internationalisation plug-in Contribution Editor Has Incorrect Keys HOT 1
- XSS vulnerability in ellipsis renderer
- Add dataRender/anchor.js to datatables.net HOT 2
- Downstream CVEs due to introduction of prettier-plugin-x HOT 8
- [Internationalization] Some languages use the incorrect specifiers for replacing data (%d instead of _START_, etc) HOT 4
- flatten is deprecated in favor of utility frameworks such as lodash HOT 2
- [email protected]: Use String.prototype.trim() instead HOT 1
- enum plugin broken since 1.13.5 HOT 1
- utf-8 encoding issue introduced recently HOT 2
- Part 2: utf-8 encoding issue introduced recently HOT 2
- [Internationalization] Pagination "of" cannot be translated HOT 1
- i18n plugin missing basic language versions for languages where country-specific versions exist HOT 1
- i18n Norwegian files incorrectly named HOT 2
- Turkish double translation HOT 3
- full_numbers_no_ellipses not working in v2 HOT 5
- Release 2.0.4 HOT 1
- i18n - language.aria keys not up to date HOT 2
- Feature searchFade does not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugins.