DataTables 1.10 beta
DataTables 1.10 beta
indymx
Posts: 63Questions: 3Answers: 0
I have am using the following code..
[code]
var date = dateFormat(new Date(), "mm-dd HH:MM");
$('#table').dataTable( {
"createdRow": function (row, data, dataIndex) {
if (data[9] == "Scheduled") {
$('td:eq(9)', row).css('background-color', '#E6FFCC').css('font-style', 'italic');
}
else if (data[8] <= date) {
$(row).class('red');
}
},
} );[/code]
table cell 9 turns green as expected, but no matter what, I never get a red row. I have checked to make sure that the date variable I'm comparing against is definitely not the issue.
the cell data is 02-26 02:00
It the old code works fine on the previous version, and if I use a similar if statement to my first one up there, I get a red cell.. Just can't seem to get the row to change.. Any ideas?
[code]
var date = dateFormat(new Date(), "mm-dd HH:MM");
$('#table').dataTable( {
"createdRow": function (row, data, dataIndex) {
if (data[9] == "Scheduled") {
$('td:eq(9)', row).css('background-color', '#E6FFCC').css('font-style', 'italic');
}
else if (data[8] <= date) {
$(row).class('red');
}
},
} );[/code]
table cell 9 turns green as expected, but no matter what, I never get a red row. I have checked to make sure that the date variable I'm comparing against is definitely not the issue.
the cell data is 02-26 02:00
It the old code works fine on the previous version, and if I use a similar if statement to my first one up there, I get a red cell.. Just can't seem to get the row to change.. Any ideas?
This discussion has been closed.
Replies
changed
$(row).class('red');
to:
$(row).prop('class', 'red');
That's a jQuery "issue". There is no jQuery method called `class()`. You might want to use `addClass()` - but the jQuery documentation is your best bet there.
Allan
You may want to change your documentation in the reference section.
Your example reads:
[code]
$('#example').dataTable( {
"createdRow": function( row, data, dataIndex ) {
if ( data[4] == "A" ) {
$(row).class( 'important' );
}
}
} );
[/code]
Fix here: https://github.com/DataTables/DataTablesSrc/commit/14f144fe0 . And the site is deploying with the fix just now :-).
Allan