Setting Row Color

Setting Row Color

lesljrlesljr Posts: 4Questions: 2Answers: 0
edited March 2019 in Free community support

This might have been asked before, but I don't see the answer in the forum. I want to change the row color after a user performs an update. Here is what I've tried. The rows have odd or even in the class

I get the row with var

_row = _mytable.row(_rowindex).node();

I've tried this but it messes up the formatting.

$(_row).removeClass().addClass('bg-success');

I've tried this below ,but the background color(odd,even) overrides the new class that I add.

$(_row).addClass('bg-success'),

I'm sure this is simple, but I can't figure it out. Can you point me in the right direction?

Answers

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    See if this example helps:
    http://live.datatables.net/loheyupe/1/edit

    Kevin

  • lesljrlesljr Posts: 4Questions: 2Answers: 0

    That is similar to what I'm doing. The problem I'm running into is The table is striped and has quite a bit of CSS. it has odd / even rows.

    <tr> role="row" class="odd">...</tr>
    <tr> role="row" class="even">...</tr>
    <tr> role="row" class="odd">...</tr>
    

    Do I need to create a class and force background-color !important ?

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @lesljr ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.