Sunday 15 May 2011

php - Highlight cell data in datatables -



php - Highlight cell data in datatables -

i'm trying highlight info in greenish showing positive growth or vice versa. i'm facing issues in chrome browser while works fine in firefox.

please help me.

$(document).ready(function() { $('#example').datatable( { "ordering": false, "columndefs": [ { "targets": 4, "createdcell": function (td, celldata, rowdata, row, col) { if ( celldata.contains("-")) // works fine firefox not chrome $(td).css('color', 'red') else $(td).css('color', 'green') } }, { "render": function ( data, type, row ) { homecoming info +' ('+ math.round(row[4]*10)/10+'%)'; },"targets": 3 } ] }); } ); </script> <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <!-- datatables css --> <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.0/css/jquery.datatables.css"> <!-- datatables --> <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.0/js/jquery.datatables.js"></script> <!--datatables--> <script src="//code.jquery.com/jquery-1.10.2.min.js"></script> <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script> <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.0/js/jquery.datatables.js"></script> <table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>metrics</th> <th>till now</th> <th>today trending</th> <th>yesterday</th> <th>dy</th> <th>5 day average</th> <th>same time lastly <?php echo date("l");?></th> <th>highest</th> <th>lowest</th> <th>target</th> <th>run rate</th> </tr> </thead> <tfoot> <tr> <th>metrics</th> <th>till now</th> <th>today trending</th> <th>yesterday</th> <th>dy</th> <th>5 day average</th> <th>same time lastly <?php echo date("l");?></th> <th>highest</th> <th>lowest</th> <th>target</th> <th>run rate</th> </tr> </tfoot> <tbody> <?php while($row = $statement->fetch(pdo::fetch_assoc)){ echo '<tr>'; echo '<td>'.'<strong>'.$row['metric'].'</strong>'.'</td>'; //till echo '<td>'.number_format($row['till_now'], 2, '.', '').'</td>'; //trending echo '<td>'.number_format($row['trending'], 2, '.', '').'</td>'; //yesterday echo '<td>'.number_format($row['yesterday'],2,'.','').'</td>'; //diff echo '<td>'.($row['trending']-$row['yesterday'])*100/$row['yesterday'].'</td>'; //5_days_avg echo '<td>'.number_format($row['5_days_avg'],2,'.','').'</td>'; //stlw echo '<td>'.number_format($row['stlw'],2,'.','').'</td>'; ?>

any help appreciated. in advance!

you need edit css , programme chrome. have tried it? edit: seek double quote marks " colors go.

php jquery google-chrome datatables compatibility

No comments:

Post a Comment