I have been working for a couple of days with DataTables and I have this task:
I need to disable the initial sorting and filter the first column which contains dates like Aug 15 depending on the fourth one (2015.08.15), which 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 sort 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 the 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:
$("#TableBt" + rid).DataTable({
"aaSorting": [],
"columns": [
null,
null,
{
"title": lC2
},
{
"visible": false
}]
This disabled my initial sorting, but it alphabetical sort my date column (the first and visible one).
After some research, I changed the code like this:
$("#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 sorting is again enable and the date sort works only alphabetical.
What am I doing wrong?