Suggestions for improving sorting, especially of personal names
Suggestions for improving sorting, especially of personal names
The examples used on the DataTables website have names in the first column, always in the format "First name Family name". Unfortunately, names so ordered cannot be sorted correctly. Wouldn't it be great to tell DataTables to use the second word? Obviously, one might have to insert
(unbreakable spaces) between the parts of the string to be treated as first name, e.g., "Johann
Sebastian Bach".
For users who have to deal with languages (or names) that contain diacriticals (e.g., acute, grave, and circumflex accents), it would be very helpful if accented letters were sorted like their unaccented counterparts instead of begin sent at the end of the list, which is sorting as it was done in the early days of computing.
Likewise, it would be helpful to be able to disregard an initial article (a, an, the, le, la, les, der, das, die, etc.), such as is found constantly in book and article titles. Another nice touch would be the possibility of disregarding an opening quotation mark, often found in book titles.
I have also observed that, when searching text using "Individual column searching (text inputs)", a string containing a curly apostrophe (coded with ’
) will not be found, since one types an ASCII apostrophe ('
) in the search box. If quotation marks and apostrophes were treated by DataTables like their plain ASCII versions, things would be easier. I am ready to admit that this last point may not be a priority since this would apply only if one copied and pasted into a search box a string found elsewhere.
This question has accepted answers - jump to:
Answers
Sure - feel free to do so :-). You can use orthogonal data to do so, or a custom ordering plug-in.
Again a plug-in would be used for this - this one strips
the
, but could readily be expanded. If you do so, please do send a pull request so others can also use it.This can also be done with a filtering plug-in, or better yet, orthogonal data with the value to want to search.
Thanks for the suggestions - all good! DataTables is designed to be flexible and not do "magic" out of the box - it causing far too much hassle to undo it, and means deadweight code for those that don't want those features.
Allan
If you use a database, the best way to handle names and titles is to store their component parts in separate fields. Those parts can then be combined quite easily for simple display purposes, with sorting and filtering achieved by using only the relevant part (e.g. last name).
I see the basic principle behind orthogonal data, which needs an additional column providing the data formatted in a way that makes correct sorting possible. Currently my website does not use a database. DataTables simply uses my static tables (and does a very nice job, I should add).
not really - you could use
columns.render
and "transform" the data as needed.Allan