Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81729

How to change cell backgroung color based on cell value using datatable

$
0
0

Request your help, I am trying to change the table cell color based on cell value using datatables using the below code but it does not work, without columnDefs it prints the values in the datatables , but when i use the columnDefs the values are printed but the cell background color does not change

            columns: [
                             { data: "Status.0", className: "text-sm-center h8 px-0", type: "num" },
                             { data: "Status.1", className: "text-sm-center h8 px-0", type: "num" },
                             { data: "Status.2", className: "text-sm-center h8 px-0", type: "num" },
                             { data: "Status.3", className: "text-sm-center h8 px-0", type: "num" },
                             { data: "Status.4", className: "text-sm-center h8 px-0", type: "num" },
                             { data: "Status.5", className: "text-sm-center h8 px-0", type: "num" },
                             { data: "Status.6", className: "text-sm-center h8 px-0", type: "num" },
                             { data: "Status.7", className: "text-sm-center h8 px-0", type: "num" }
                           ],
           columnDefs: [ {
                           targets: [ 0, 1, 2, 3, 4, 5, 6, 7 ],
                           render: function(data, type, row, meta){
                           return data = 0 ? '<td class="bg-success view_data" data-toggle="modal"></td>': data;''
                           return data = 1 ? '<td class="bg-danger view_data" data-toggle="modal">Error</td>': data;
                           return data = 2 ? '<td class="bg-warning view_dat"' data-toggle="modal">Warnings</td>': data;
                           return data = 3 ? '<td class="bg-info view_data"></td>': data;
                           }
                         }
                        ],

Viewing all articles
Browse latest Browse all 81729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>