Datatables: Change cell color based on values

First of all, initialize DataTable only once. Then as per your question, use rowCallback and not fnRowCallBack as shown below: var oTable = $(‘#countryTable’).DataTable({ ‘rowCallback’: function(row, data, index){ if(data[3]> 11.7){ $(row).find(‘td:eq(3)’).css(‘color’, ‘red’); } if(data[2].toUpperCase() == ‘EE’){ $(row).find(‘td:eq(2)’).css(‘color’, ‘blue’); } } }); Here’s a fiddle

How to add attribute in TR and TD?

Use createdRow and columns.createdCell options to define a callback function that will be called when TR and TD element are created. $(‘#example’).dataTable( { ‘createdRow’: function( row, data, dataIndex ) { $(row).attr(‘id’, ‘someID’); }, ‘columnDefs’: [ { ‘targets’: 3, ‘createdCell’: function (td, cellData, rowData, row, col) { $(td).attr(‘id’, ‘otherID’); } } ] }); See this example … Read more

Change the default number of rows to display on one “page”

For DataTables version 1.10.5 and newer, as documented on the blog post announcing the integration of HTML5 data-* attributes, the number of rows to show per page can be specified via the source (HTML) table through the data-page-length attribute: <table data-page-length=”25″> … </table> For DataTables version 1.10 and newer, as documented at Reference > Options … Read more

dataTable() vs. DataTable() – why is there a difference and how do I make them work together?

Basically, the two constructurs return different objects. dataTable constructor var table = $(<selector>).dataTable() dataTable is the oldschool dataTables constructur, which returns a jQuery object. This jQuery object is enriched with a set of API methods in hungarian notation format, such as fnFilter, fnDeleteRow and so on. See a complete list of API methods here. Examples … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)