I have been working with DataTables for a couple of days, and I have this task: I need to disable the initial sort and filter the first column, which contains the type dates Aug 15
depending on the fourth ( 2015.08.15
) that will be hidden.
For example, if I have:
Aug 15 | 2015.08.15
Aug 7 | 2015.08.07
Aug 3 | 2015.08.03
Aug 20 | 2015.08.20
In ascending order, I should get:
Aug 3 | 2015.08.03
Aug 7 | 2015.08.07
Aug 15 | 2015.08.15
Aug 20 | 2015.08.20
But I get an alphabetical sort:
Aug 15 | 2015.08.15
Aug 20 | 2015.08.20
Aug 3 | 2015.08.03
Aug 7 | 2015.08.07
My first code was something like this:
$("#TableBt" + rid).DataTable({
"aaSorting": [],
"columns": [
null,
null,
{
"title": lC2
},
{
"visible": false
}]
This disabled my initial sort, but it sorts alphabetically my date column (first and visible).
After some research, I changed the code as follows:
$("#TableBt" + rid).dataTable({
"asSorting": [],
"aoColumnDef": [
{
"iDataSort": 3,
"aTargets": [4]
},
null,
{
"sTitle": lC2
},
{
"bVisible": false,
"aTargets": [3]
}]
});
But now all the columns are visible, the initial sort is turned on again and the date sort only works in alphabetical order.
What am I doing wrong?