Here's the page:
I need to sort by the Date Column, right now it needs to read Nov 6, Nov 5 and lastly Oct 7.
How do I do this?
Here's the page:
I need to sort by the Date Column, right now it needs to read Nov 6, Nov 5 and lastly Oct 7.
How do I do this?
Your Current Code:
What you could do:
But as pointed out in the comment below, this may be a cleaner method:
$('#id').dataTable( {
""aaSorting": [[ "0", "<"desc" or asc>"]]
});
The existing answers are using legacy DataTables syntax. Versions 1.10+ should use the following syntax:
Reference:
DataTables uses Alphabetical order as the default sorting method. This is actually what happens here.
There are two solution:
If you want your users to be able to sort the column by themselves you might use the first solution.
--------------- First Solution:
We need to tell the DataTable plugin what to do with our columns. You'll need to use the "aoColumns" property:
Then define the "shaheenery-date-asc" and "shaheenery-date-desc" sorting method. You also need a function "getDate" that translate the date in numeric format:
--------------- Second Solution:
We are going to use the "aoColumns" property as well. This time we tell DataTable to hide the last column which will contains the date in Unix Timestamp. We also need to define this column as the default one for sorting with "aaSorting":