Date Sorting not working in Firefox & I. Explorer.
Date Sorting not working in Firefox & I. Explorer.
Hi there,
I'm new here so first of all, just say that DataTables is really a great feature:)
Now regarding to my problem, I have a column with the format (Month Year) that is sorting properly in Chrome, but is not working in Firefox and Internet Explorer.
Here is the code:
$(document).ready(function() {
$('#resultados').dataTable( {
"sPaginationType": "full_numbers",
"aaSorting":[[2, "desc"]],
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [ 1,4 ] }, ],
"aLengthMenu": [[25, 50, 75, 100], [25, 50, 75, 100]],
"iDisplayLength": 100
} );
} );
Hope somebody can help me because I can't find where the problem is!
Thanks in advance
I'm new here so first of all, just say that DataTables is really a great feature:)
Now regarding to my problem, I have a column with the format (Month Year) that is sorting properly in Chrome, but is not working in Firefox and Internet Explorer.
Here is the code:
$(document).ready(function() {
$('#resultados').dataTable( {
"sPaginationType": "full_numbers",
"aaSorting":[[2, "desc"]],
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [ 1,4 ] }, ],
"aLengthMenu": [[25, 50, 75, 100], [25, 50, 75, 100]],
"iDisplayLength": 100
} );
} );
Hope somebody can help me because I can't find where the problem is!
Thanks in advance
This discussion has been closed.
Replies
http://datatables.net/development/sorting
http://datatables.net/plug-ins/sorting
Allan
I found a script that may solve my problem. But I dont know how to include it in my code.
Can you give me a hand?
Is the plugin Month Year:
Here is the code:
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"monthYear-pre": function ( s ) {
var a = s.split(' ');
// Date uses the American "MM DD YY" format
return new Date(a[0]+' 01 '+a[1]);
},
"monthYear-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"monthYear-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
Should I save it as a separated .js file?
How will recognize the plugin my column?
Please help
Allan
Please take a look to my code, I dont know which step Im doing wrong.
Thanks in advance
Query.extend( jQuery.fn.dataTableExt.oSort, {
"monthYear-pre": function ( s ) {
var a = s.split(' ');
// Date uses the American "MM DD YY" format
return new Date(a[0]+' 01 '+a[1]);
},
"monthYear-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"monthYear-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
$(document).ready(function() {
$('#resultados').dataTable( {
"sPaginationType": "full_numbers",
"aaSorting": [] ,
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [ 1,4 ] },
{ "sType": "monthYear", "aTargets": [ 2 ] },
],
"aLengthMenu": [[25, 50, 75, 100], [25, 50, 75, 100]],
"iDisplayLength": 100
} );
} );
Allan
Thanks
Allan