Update . The initial answer was targeted at dataTables 1.9.x. It still works and works with dataTables 1.10.x (for now), but here is a clean version of dataTables 1.10.x:
var table = $('#example').DataTable({ rowCallback: function(row, data, index) { if (data[3]=='0' && data[4]!='0') { $(row).find('td:eq(3)').addClass('color') } } })
demo β http://jsfiddle.net/2chjxduy/
For this you should use fnRowCallback . From the docs:
This function allows you to "send" each row after it has been generated for each draw of the table, but before it is displayed on the screen. This function can be used to set the class name of a string, etc.
So in your case do the following:
$("#GeneratedData").dataTable({
color is a predefined CSS class. See this in action in this jsfiddle -> http://jsfiddle.net/GfNeA/
davidkonrad
source share