javascript - rowCallback and createdRow not highlighting row - Stack Overflow

I followed the documentation from the Jquery Datatable site, as well as SO posts,to use rowCallback t

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');
    }
    }
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745179401a4615350.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信