Date Comparison not working (using v1.10)
Date Comparison not working (using v1.10)
From the http://live.datatables.net jsbin, this code works:
$(document).ready( function () {
var table = $('#example').DataTable( {
ajax: '/ajax/arrays.txt',
createdRow: function ( node, data ) {
var dtDue = Date.parse(data[4]);
var dtTst = Date.parse('2011-04-30');
if ( dtDue < dtTst ) {
$(node).addClass( 'highlight' );
}
}
} );
} );
but then when I place it into my situation, modifying the code for the differences needed, this does NOT work: can anyone please explain what I'm doing wrong? I've spent untold hours trying to get this to work. Maybe I've gotten too close and just can't see the forest thing... Any assistance would be greatly appreciated. Is it version 9 versus version 10 element naming thats grabbing me? As I see it:
- The table name is different (should not matter).
- The working set is ajax with server side processing (data should be data).
dtTst was renamed dtNow and the definition changed but they were also changed in the comparison which again should not matter. In a separate jsbin test the code "var dtNow = Date.parse(new Date())" evaluates properly and that comparison works.
$(document).ready(function() {
var table = $('#unfiled').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "server_masters.php",
"aaSorting": [9,'asc'],createdRow: function ( node, data ) { var dtDue = Date.parse(data[4]); var dtNow = Date.parse(new Date()); if ( dtDue < dtNow ) { $(node).addClass( 'highlight' ); } } } );
} );
The applicable CSS in both cases is:
tr.highlight td {
background-color: #FF7F50;