• Resolved rakelbara

    (@rakelbara)


    Hello Tobias
    I’m sorry to be bothering you but I have a sorting issue with a table that I hope you can help me with. I tried searching for answers in the forum, but was unable to find the correct solution.

    First of all, the table is in Icelandic but the 2nd column does not sort correctly (in Icelandic) alphabetically.

    The Icelandic alphabet looks like this:
    A, á, B, D, D, E, é, F, G, H, I, í, J, K, L, M, N, O, ó, P, R, S, T, U, ú, V, X, Y, Y, T, ?, ?
    But if you look at the 2nd column, you can see that á and ó are placed before T, which is incorrect.
    I have added the locale to my shortcode so it now it looks like this:
    [table id=12 datatables_locale=”is_IS” /]

    But unfortunately that does not work.

    —————-
    My second issue is with sorting the date. I would like to have the dates in Icelandic; like this f.ex.:
    1. des. 2018
    25. jan. 1992
    12. sept. 1873
    But I could not get that to sort correctly – it only sorted by the first number like this:
    1. des. 2018
    12. sept. 1873
    25. jan. 1992
    Which is chronologically incorrect. So I changed the dates to this format: dd-mm-yyyy but it still would not sort correctly.

    I have added the plugin “DataTables Sorting plugins” and tried adding:
    “columnDefs”: [ { “type”: “formatted-num”, “targets”: [ 3 ] } ]
    and
    “columnDefs”: [ { “type”: “date-eu”, “targets”: [ 3 ] } ]

    But nothing worked.

    Do you have any ideas on how I could fix these two issues?

    Thank you in advance
    Rakel

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Unfortunately, I don’t really have ideas here. The DataTables JavaScript library by default only supports the Latin alphabet (as this is directly implemented in character encodings and therefore easy to sort). You would need a custom sorting algorithm for the Islandic alphabet, i.e. you would have to “teach” the JS library which order the letters are in.
    Unfortunately, I don’t know how that is possible, but can only point you to the DataTables documentation at https://www.datatables.net/

    The problem with the dates is very similar. The algorithm simply doesn’t know the Islandic month names. For this, I’d recommend the approach from https://www.ads-software.com/support/topic/date-order-6/

    Regards,
    Tobias

    Thread Starter rakelbara

    (@rakelbara)

    Hello again Tobias and thank you for your reply.

    But should the “system” not be able to understand the date “dd-mm-yyyy” in the form 30-12-2018? That is a European standard for dates, I would think?

    Best regards
    Rakel

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    the “date-eu” algorithm understands “dd.mm.yyyy” best, from what I can see.
    Could you please try that?

    Regards,
    Tobias

    Thread Starter rakelbara

    (@rakelbara)

    Hi again

    If I add

    “columnDefs”: [ { “type”: “date-eu”, “targets”: [ 3 ] } ]

    The sorting disappears. Should I try something else?

    Best regards
    Rakel

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Rakel,

    you need to be careful with the quotation marks here:

    "columnDefs": [ { "type": "date-eu", "targets": [ 3 ] } ]
    

    Also, please make sure that you installed and activated the TablePress Extension from https://tablepress.org/extensions/datatables-sorting-plugins/
    And finally, keep in mind that the 3 in this code would refer to the fourth column of the table (as counting the columns starts with 0).

    Regards,
    Tobias

    Thread Starter rakelbara

    (@rakelbara)

    Hello Tobias

    Thank you for your reply. I had not noticed the quotation marks, thanks for that tip.
    I have now changed the code to what you suggested:
    "columnDefs": [ { "type": "date-eu", "targets": [ 2 ] } ]

    But now the sorting for column no. 2 is completely disabled. Any idea what could be wrong now?

    The page is:
    https://www.hafdal.dk/legstadaleit/index.php/skipsskadar/

    Thread Starter rakelbara

    (@rakelbara)

    Hello again!
    Sorry, I found a value in the column that was formatted incorrectly and once I fixed that, everything worked fine ??
    Happy New Year!
    Best regards
    Rakel

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Sorting issues’ is closed to new replies.