different rows BG color according to content

different rows BG color according to content

muflomuflo Posts: 11Questions: 0Answers: 0
edited November 2010 in General
Hello there,
is there any chance to have datatables apply a particular backgroud color to a row if one of his fields contains a gived word?

Replies

  • rdahlrdahl Posts: 12Questions: 0Answers: 0
    muflo,
    you could do this with the fnRowCallback, see http://www.datatables.net/usage/callbacks for usage, but basically
    [code]
    $('#example').dataTable( {
    "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
    if ( aData[4] == "given word" )
    {
    $('td:eq(4)', nRow).addClass( 'particular-background-color' );
    }
    return nRow;
    }
    } );
    [/code]
  • xionhackxionhack Posts: 5Questions: 0Answers: 0
    Sorry! I didn't specify! A PHP function. I'm using the server side
This discussion has been closed.