Change colors of multiple cells in row

Change colors of multiple cells in row

johnbeljohnbel Posts: 2Questions: 1Answers: 0

I am trying to change colors of multiple cells on a row. Right now only the second target gets changed. What do I need to do differently to get results for both cells? Is there a better method to achieve what I'm trying to do?

        columnDefs: [
        {
            targets: 9,
            createdCell: function (td, cellData, rowData, row, col) {
                switch ( cellData) {
                    case "Offline":
                        $(td).css('color', 'red')
                        break;
                    case "Decomm":
                        $(td).css('color', 'blue')
                        break;
                    case "Online":
                        $(td).css('color', 'green')
                        break;
                    case "BeingBuilt":
                        $(td).css('background', 'yellow')
                        break;
                    case "PoweredOff":
                        $(td).css('color', 'red')
                        break;
                }
            },
            targets: 10,
            createdCell: function (td, cellData, rowData, row, col) {
                var t = parseInt(cellData);
                if ( t > 180) {  $(td).css('background', 'red');} else
                if ( t > 150) {  $(td).css('background', 'yellow');}
            }
        }]

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.