use variable to add dynamic class to a dolumn

use variable to add dynamic class to a dolumn

erickpezoaerickpezoa Posts: 1Questions: 1Answers: 0

I am trying to add to column 8 a class which will be "transState " + variable. I am trying to figure out how to add that variable inside the columnDefs. Take a look below. I have columnDefs and the className parameter targeting column 8. To column 8, I want to the add the class name "transState " + row.RECIBO. What should I do to accomplish that?

$(document).ready(function() {
                            
    var table = $('#tableCLIX1').DataTable({
        
    "order": [[0, "desc" ]],
    "ajax": {"url": "reciboBackend.php", "type": "POST", "dataSrc": "db" },
    "columnDefs": [{
        "render": function(data, type, row){ return row.RECIBO},
        "targets": 8,
        "className": "class name with variable row.RECIBO goes here"
    }],
    "columns": [
    {"data": "RECIBO", "className": "recibo"},
    {"data": "NOMCLI"},
    {"data": "CLIENTE"},
    {"data": "FECHA"},
    {"data": "NUMPOL"},
    {"data": "FACTURA"},
    {"data": "TIPO"},
    {"data": "VALOR"},
    {"mRender": function(data, type, full){if(full["TRANSTATE"] == null) return "<button id = 'cancelar" + full["RECIBO"] + full["FACTURA"] + "' class='button-error pure-button cancelar-btn " + full["RECIBO"] + "' > Cancelar </button>"; else return full["TRANSTATE"];}},
    {"mRender": function(data, type, full, meta){return '<a href = "reImprimir.php?recibo=' + full["RECIBO"] + '+&tranState=' + full["TRANSTATE"] + '" target = "_blank"> Imprimir </a>';}}
    ],
    "deferRender": true

});

This discussion has been closed.