Problem sorting dates like 12/19/1962, fnRender
Problem sorting dates like 12/19/1962, fnRender
I am having problems getting dates to sort correctly. I'm using the eu_date plug in; server side processing.
The dates are sorting as a string, so that they sort like: 12/04/1979, 12/04/1973, 12/04/1973, 12/03/2002.
I would expect them to sort like a date: 12/04/1973, 12/04/1973, 12/04/1979, 12/03/2002
ie, years should be together, then months, then days.
In my server side php page, I have the following:
[code]
$aColumns = array('SUBJECT_ID', 'SUBJECT_NAME', 'SUBJECT_TEXT', 'DATE_FORMAT(SUBJECT_DATE,"%m/%d/%Y")', 'IMAGE_NOW' );
[/code]"
That displays the date in the correct format, 12/19/1962.
I'm using the following to initialze my table:
[code]
$(document).ready(function() {
$('#static').addClass("js_enabled");
$('#dynamic').removeClass("js_enabled");
oTable = $('#aac_index').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bDeferRender": true,
"sDom": 'lfript',
"aaSorting": [[0,'asc'], [1,'asc'], [2,'asc']],
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"bSortClasses": true,
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumns": [ {"bVisible": true},
{"sWidth": "125PX" ,
"fnRender": function ( o ) {
var row_subject_date = o.aData[ o.iDataColumn+2];
return ''+o.aData[ o.iDataColumn]+'';
}},
{"sWidth": "300PX" },
{"sWidth": "80PX", "sType": "eu_date" ,
"fnRender": function ( o ) {
var row_subject_date = o.aData[ o.iDataColumn];
return ''+row_subject_date+'';
}},
{"bVisible": false }],
"sAjaxSource": '/apps/aac_server_processing.php'
} );
[/code]
The dates unfortunately do not sort in the correct order.
I'm wondering if the fnRender might be causing problems?
If not, any other suggestions? I have dataTables.dateFormat.js included in my html file, just after I include datatables, and just before my js file with the data tables initialization.
Any suggestions apprecitated!
Thanks
Jim
The dates are sorting as a string, so that they sort like: 12/04/1979, 12/04/1973, 12/04/1973, 12/03/2002.
I would expect them to sort like a date: 12/04/1973, 12/04/1973, 12/04/1979, 12/03/2002
ie, years should be together, then months, then days.
In my server side php page, I have the following:
[code]
$aColumns = array('SUBJECT_ID', 'SUBJECT_NAME', 'SUBJECT_TEXT', 'DATE_FORMAT(SUBJECT_DATE,"%m/%d/%Y")', 'IMAGE_NOW' );
[/code]"
That displays the date in the correct format, 12/19/1962.
I'm using the following to initialze my table:
[code]
$(document).ready(function() {
$('#static').addClass("js_enabled");
$('#dynamic').removeClass("js_enabled");
oTable = $('#aac_index').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bDeferRender": true,
"sDom": 'lfript',
"aaSorting": [[0,'asc'], [1,'asc'], [2,'asc']],
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"bSortClasses": true,
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumns": [ {"bVisible": true},
{"sWidth": "125PX" ,
"fnRender": function ( o ) {
var row_subject_date = o.aData[ o.iDataColumn+2];
return ''+o.aData[ o.iDataColumn]+'';
}},
{"sWidth": "300PX" },
{"sWidth": "80PX", "sType": "eu_date" ,
"fnRender": function ( o ) {
var row_subject_date = o.aData[ o.iDataColumn];
return ''+row_subject_date+'';
}},
{"bVisible": false }],
"sAjaxSource": '/apps/aac_server_processing.php'
} );
[/code]
The dates unfortunately do not sort in the correct order.
I'm wondering if the fnRender might be causing problems?
If not, any other suggestions? I have dataTables.dateFormat.js included in my html file, just after I include datatables, and just before my js file with the data tables initialization.
Any suggestions apprecitated!
Thanks
Jim
This discussion has been closed.