using "createdRow" to change style -- style change does not display

using "createdRow" to change style -- style change does not display

dgotlibdgotlib Posts: 2Questions: 1Answers: 0

Hello again.
2 questions.
(1) I'm using createdRow to change the background color of a table row if two dates int he row are > 14 days apart. The calculation works ok, and the command to add a special class to the row works -- because I see it added in the debugger,
but the row does not change color in the table.

The modified <tr> reads
<tr class="delinquent odd">
and the class "delinquent" is defined as
.delinquent {background-color:blue;}

When I look at the Elements view
there is a strikethrough in the background-color:blue; command, suggesting to me that another css background-color is taking precedence
(see https://dl.dropboxusercontent.com/u/49189/gotlib1.tiff for screencapture)

Can you help?

(2) using the same "createdRow" function
is there a way to modify the style of a <td> cell?

Thanks
David Gotlib

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Hi David,

    Thanks for the details and the screenshots. You are quite correct that another rule is taking priority - specifically the one shown at the top of the CSS list in your screenshot from table.dataTable.stripe tbody tr.odd .

    There are a few options that spring to mind:

    1. Disable the row stripe class options (remove the display class from your table, padding adding others such as row-border if needed).
    2. Make your rule higher priority by adding `!important!
    3. Have a look in the DataTables stylesheet to see how it handles the selected class and you could basically do the same. Or you could even use the selected class.

    using the same "createdRow" function is there a way to modify the style of a <td> cell?

    Yes, you have the tr element, it is passed into the callback, so you can just manipulate it as you wish using jQuery:

    $('td:eq(2)', tr).css( 'color', 'red' );
    

    for example.

    Allan

  • dgotlibdgotlib Posts: 2Questions: 1Answers: 0

    Using '!important! solves the problem
    and including the :eq jQuery in the createdRow section works nicely.

    One more question:
    createdRow works only when a row is created (right?)
    but how do I run the same code in createdRow
    on a row whose content is changed by inline-editing?

    Thanks
    David

This discussion has been closed.