I have a table in my Rails application which displays a single column of dates, written in US long form (Month DD, YYYY).
Using a default dataTable, I noticed that these date strings are sorted alphabetically, rather than by date. Clicking the column header will sort those strings in ascending or descending order as expected, but alphabetically.
I tried to get the datatable to properly sort by date by modifying my CoffeeScript to include columnDefs, as follows:
$('.scheduled_activities').dataTable(
columnDefs: [ { 'type': 'date', 'targets': 0 } ]
)
After altering the script, the datatable now displays the dates in ascending order. Clicking on the column header, however, does absolutely nothing -- dates are not sorted in descending order.
How can I get datatables to recognize the column values as dates while retaining the ability to sort in asc/desc order by clicking on the column header? I'm using JQuery 1.11.2, and I'd like to stick with a solution with as few dependencies as possible, so using libraries like moment.js are a last resort. Thanks for any assistance.