Sort date/times enclosed in time elements
Sort date/times enclosed in time elements
rink_attendant_6
Posts: 16Questions: 4Answers: 1
Related issue: http://www.datatables.net/forums/discussion/12953/sort-table-by-html5-data-value/p1
Many tables have columns of date/time values and it would be nice to sort these based on the datetime attribute of the HTML5 time element. I think it might be more efficient as well to do this than to do string parsing.
Here's a simple example: http://jsfiddle.net/J4Mxz/
The sorting of the second and third columns should be the exact same since they both have the same values, but the second column is being treated as a string instead of a date.
I realize that there is already a way to do this by defining my own sort function by adding a property to $.fn.dataTableExt.oSort, but it seems inefficient. I also tried forcing the column sType to be "date" but I guess the HTML tags get in the way.
Many tables have columns of date/time values and it would be nice to sort these based on the datetime attribute of the HTML5 time element. I think it might be more efficient as well to do this than to do string parsing.
Here's a simple example: http://jsfiddle.net/J4Mxz/
The sorting of the second and third columns should be the exact same since they both have the same values, but the second column is being treated as a string instead of a date.
I realize that there is already a way to do this by defining my own sort function by adding a property to $.fn.dataTableExt.oSort, but it seems inefficient. I also tried forcing the column sType to be "date" but I guess the HTML tags get in the way.
This discussion has been closed.