Coloring Row ,if column "Jenis" Contain "DB" And CR"

Coloring Row ,if column "Jenis" Contain "DB" And CR"

tjhauwentjhauwen Posts: 1Questions: 1Answers: 0

im very tired of my codes , how can to add a color in row
i think im already correct but not working

var table = $('#datatable-json').DataTable({
"pageLength": -1,

              dom: 'Bfrtip',
    buttons: [

        extend: 'excelHtml5',
        autoFilter: true,
        sheetName: 'INI BOS',
        title: 'INI BOSQUE'
    ] ,
    select: false,
    data: response,
               "columns": [
                    { "data": "Id" },
                    { "data": "Tanggal" },
                    { "data": "Keterangan" },
                    { "data": "Jumlah" },
                    { "data": "Jumlah2" },
                    { "data": "Jenis" },
                    { "data": "Saldo" }       

    responsive: false,
    destroy: true

//Tip from this user kthorngren: absolute not working
rowCallback: function( row, data, index ) {
if ( data.Jenis == "DB" ) {$(row).addClass('green');}
else if ( data[3] == "CR" ) {$(row).addClass('orange');}
else if ( data[3] == "30" ) {$(row).addClass('red');}




  • colincolin Posts: 12,939Questions: 0Answers: 2,204

    if ( data.Jenis == "DB" ) {$(row).addClass('green');}

    This style should work, as your data is object based, the other two lines won't as you also need to reference the object.

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.



Sign In or Register to comment.