row highlighting based on value

row highlighting based on value

ducati1212ducati1212 Posts: 2Questions: 0Answers: 0
edited May 2011 in General
I added a simple line under document .ready to highlight rows based on value returned from my query

$(document).ready(function() {
$('#example').dataTable();
$('tr').find('td:eq(6):contains(null)').parent().css('backgroundColor', 'yellow'); // this does row higlingting broke right now
} );

This code works except for paging. So when I go to page 2 of my results highlighting does not happen? Is there an easier way to highlight rows based on a value. the code is just PHP

Replies

  • the3rdbitthe3rdbit Posts: 8Questions: 0Answers: 0
    edited May 2011
    When you initialize the DataTable before the colorizing, there ist only the visible part of the table available. Colorize the content of the entire table before you initialize the datatable!

    Try something like this:
    [code]
    $(document).ready(function() {

    $('table#example')
    .find("tr").find('td:eq(6):contains(null)').parent().css('backgroundColor', 'yellow') // row higlingting
    .dataTable();
    });
    [/code]
  • ducati1212ducati1212 Posts: 2Questions: 0Answers: 0
    bingo not 100% as you showed but you had the right idea. Always the simple stuff that gets me

    Thanks
  • the3rdbitthe3rdbit Posts: 8Questions: 0Answers: 0
    edited May 2011
    I had a similar problem lately...
    That's right, the semicolon after the 4. line was wrong, I've corrected it.
This discussion has been closed.