Conditional Row Background

Conditional Row Background

mrprice22mrprice22 Posts: 10Questions: 4Answers: 0

So I'm using the following to set the background row of a table that has the followiing bootstrap classes applied.

class="table table-striped table-bordered table-responsive"

This seems to work only on the even rows. Any ideas why?

createdRow: function(row, data, dataIndex) {
        if (data.name.trim() == 'BODYPUMP') {
            $(row).css({"background-color":"red"});
                $(row).addClass('sub-needed');
     }
}

Answers

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    Seems to apply the background to odd or even rows in this example:
    http://live.datatables.net/vecaside/1/edit

    Its using Bootstrap 3 and the table class you specified. Maybe you can update the test to replicate the issue.

    Kevin

  • mrprice22mrprice22 Posts: 10Questions: 4Answers: 0

    I've added this to my css and that seems to be the problem.

    http://live.datatables.net/vecaside/2/edit

    .table-striped>tbody>tr:nth-child(odd)>td,
    .table-striped>tbody>tr:nth-child(odd)>th {
       background-color: #585a5e; 
    }
    
  • mrprice22mrprice22 Posts: 10Questions: 4Answers: 0

    I resolved it by getting rid of the bootstrap table-striped class and using the following.

    stripeClasses: [ 'odd-row', 'even-row' ],

This discussion has been closed.