How to customize a field in Server-side processing(Data Table)

How to customize a field in Server-side processing(Data Table)

cravindrcravindr Posts: 1Questions: 1Answers: 0

HI all
I want to customize a field's appearance in Server-side processing(Data Table). I want to change the color of the text any idea...
in please see the attachment's status fields..
thanks

Answers

  • DirceuNazarethDirceuNazareth Posts: 44Questions: 1Answers: 12

    In the object that correspond to the column you can do:

    //in the JS file..
    { 
       data: status,
       className: "status-class"
    }
    

    in the CSS

    .status-class{
        color: #000000;
    }
    

    if it is a dynamic case you can use columns.createdCell:

    { 
       data: status,
       createdCell: function( cell, cellData, rowData, rowIndex, colIndex ){
             var color = "white"
             switch(cellData){
                  case "inactive":
                     color = "red";
                      break;
                  case "stopped":
                     color: "yellow"
                     break;
                   default:
                      //leave it white
              }
              $(cell).css("color", color);
       }
    }
    
This discussion has been closed.