• Resolved andrejmikula

    (@andrejmikula)


    Hi,
    The date collumn DD.MM.YYYY in my table doesnt get sorted. It sort based alphabeticaly only (based on DD), so for example 01.10.2014 is before 21.07.2014.

    DataTables Sort plugin is installed and activated.

    I also tried this, but it didnt work 🙁
    “aoColumnDefs”: [ { “sType”: “date-eu”, “aTargets”: [ 0 ] } ]`

    Please help me, let me know what I should do. Thank you very much in advance.
    Andrej

    https://wordpress.org/plugins/tablepress/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!

    Regards,
    Tobias

    Thread Starter andrejmikula

    (@andrejmikula)

    Hi Tobias,
    thank you very much.
    This is the link of my website: http://www.timemanagement.sk/tablepress-test/

    The funny thing is, that it sort of works now, but I had to switch the language from Slovak to English in the Settings part of TablePress. But it only works partialy, because user cant choose between sorting ASC and DESC…

    Regards,
    Andrej

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for the link! From what I can see, the problem might be the spaces between the day, month, and year. The sorting algorithm can not recognize those.

    Regards,
    Tobias

    Thread Starter andrejmikula

    (@andrejmikula)

    Oh, it doesnt work anyway. I noticed that I manually sort the table. So it wasnt sorting at all. If you look there now, you can see that it’s not sorted and clickiing on the <thead> doesnt do anything. And yes I removed the spaces…

    Thread Starter andrejmikula

    (@andrejmikula)

    Is this code good for my case?

    "aoColumnDefs": [ { "sType": "date-eu", "aTargets": [ 0 ] } ]

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, that code is totally correct.

    Now I found the reason for this: Your theme has some JavaScript code built-in to make the table responsive (when you view it on a small screen). It does that by adding some extra HTML code to the beginning of each cell, which you can see e.g. by inspecting the table with the Google Chrome Developer Tools. This HTML code then breaks the sorting, as the DataTables JS library just can’t know what to do with it.
    That JS code in the theme is in the section // Responsive tables in the file /wp-content/themes/SimplicityNew/js/gk.scripts.js. I suggest to temporarily remove that.

    Regards,
    Tobias

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘DD.MM.YYYY sorting not working. DataTables Sorting plugin activated’ is closed to new replies.