Chaining default sort and html sort
Chaining default sort and html sort
I have a table with six columns.
The last column contains dates, which are wrapped in a span tag so that they can be manipulated by ID.
I would like to:
1. Set the default sort on the table to the last column.
2. Have DataTables recognize the date as a date, not just as a string.
The following code gets me there, but doesn't sort dates properly:
[code]
$(document).ready(function() {
$('#myTable').dataTable( {
"aaSorting": [[ 5, "asc" ]],
"aoColumns": [
null,null,null,null,null,
{ "sType": "html" }
]
} );
} );
[/code]
In the docs, there is a Column option for "asSorting", which I would like to use instead of the "aaSorting" in the example above.
However, for some reason, I can't get asSorting to set up the defaults, nor work in a chain with the "sType": "html" segment.
I removed all of the SPAN tags and then removed the "sType": "html" segment so I could work directly with "asSorting ", but I could never get it to sort "asc". It always sorted with the latest date first.
I guess I don't understand the proper usage of asSorting, but I have tried just about every combination I can think of.
What I am aiming for is something like this:
[code]
$(document).ready(function() {
$('#myTable').dataTable( {
"aoColumns": [
null,null,null,null,null,
{ "sType": "html", "asSorting": [ "asc" ] }
]
} );
} );
[/code]
Unfortunately, the documentation at http://www.datatables.net/usage/columns is not telling me much about how to use "asSorting".
Please help me understand what I am missing.
Thanks so much.
The last column contains dates, which are wrapped in a span tag so that they can be manipulated by ID.
I would like to:
1. Set the default sort on the table to the last column.
2. Have DataTables recognize the date as a date, not just as a string.
The following code gets me there, but doesn't sort dates properly:
[code]
$(document).ready(function() {
$('#myTable').dataTable( {
"aaSorting": [[ 5, "asc" ]],
"aoColumns": [
null,null,null,null,null,
{ "sType": "html" }
]
} );
} );
[/code]
In the docs, there is a Column option for "asSorting", which I would like to use instead of the "aaSorting" in the example above.
However, for some reason, I can't get asSorting to set up the defaults, nor work in a chain with the "sType": "html" segment.
I removed all of the SPAN tags and then removed the "sType": "html" segment so I could work directly with "asSorting ", but I could never get it to sort "asc". It always sorted with the latest date first.
I guess I don't understand the proper usage of asSorting, but I have tried just about every combination I can think of.
What I am aiming for is something like this:
[code]
$(document).ready(function() {
$('#myTable').dataTable( {
"aoColumns": [
null,null,null,null,null,
{ "sType": "html", "asSorting": [ "asc" ] }
]
} );
} );
[/code]
Unfortunately, the documentation at http://www.datatables.net/usage/columns is not telling me much about how to use "asSorting".
Please help me understand what I am missing.
Thanks so much.
This discussion has been closed.