DataTables 1.10 beta

DataTables 1.10 beta

indymxindymx Posts: 63Questions: 3Answers: 0
edited February 2014 in DataTables 1.10
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?

Replies

  • indymxindymx Posts: 63Questions: 3Answers: 0
    I got it working..

    changed

    $(row).class('red');

    to:

    $(row).prop('class', 'red');
  • allanallan Posts: 54,880Questions: 1Answers: 8,601 Site admin
    > $(row).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
  • indymxindymx Posts: 63Questions: 3Answers: 0
    edited February 2014
    I took that code right from your page on the createdRow option.

    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]
  • allanallan Posts: 54,880Questions: 1Answers: 8,601 Site admin
    Yeah - the documentation is bo**ocks there. Apologies!

    Fix here: https://github.com/DataTables/DataTablesSrc/commit/14f144fe0 . And the site is deploying with the fix just now :-).

    Allan
  • indymxindymx Posts: 63Questions: 3Answers: 0
    It's ok.. I didn't spend a lot of time on it before I found the fix.
This discussion has been closed.