admin管理员组

文章数量:1415654

I followed the documentation from the Jquery Datatable site, as well as SO posts, to use rowCallback to highlight the row based on value.

let SET1 = $("#SET1").DataTable({
    "columns": columns,
    "rowCallback": function( row, data, index ) {
    if ( data[0] == "jon" )
    {
        $('td', row).css('background-color', 'Red');
    }
    }
});

However, nothing I have tried rowCallback,createdRow or the fnrowCallback is making the row to change color. Is it the way I'm loading the data?

below is my fiddle. /

I followed the documentation from the Jquery Datatable site, as well as SO posts, to use rowCallback to highlight the row based on value.

let SET1 = $("#SET1").DataTable({
    "columns": columns,
    "rowCallback": function( row, data, index ) {
    if ( data[0] == "jon" )
    {
        $('td', row).css('background-color', 'Red');
    }
    }
});

However, nothing I have tried rowCallback,createdRow or the fnrowCallback is making the row to change color. Is it the way I'm loading the data?

below is my fiddle. http://jsfiddle/czcz/qfr3xLq1/5/

Share Improve this question asked Apr 27, 2017 at 20:17 causitacausita 1,7081 gold badge23 silver badges35 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

rowCallback is called once for each row. It is not an array, but an object. Try this:

let SET1 = $("#SET1").DataTable({
    "columns": columns,
    "rowCallback": function( row, data, index ) {
    if ( data.name == "jon" )
    {
        $('td', row).css('background-color', 'Red');
    }
    }
});

本文标签: javascriptrowCallback and createdRow not highlighting rowStack Overflow