JQuery JTable根据某行的某个值来设置行的背景颜色

目录

某个表的数据是用JQuery的JTable插件进行展示的。现在需求是:当表中的master字段为true时,就将对应的整行的背景颜色设置为浅蓝色。

处理方法

在fields:{},后面添加:

rowInserted: function (event, data) { //若是当前主节点,整行显示不一样的颜色(浅蓝色)
    if (data.record) {
        if (data.record.master == true) {
            data.row.css("background", "#C0D9D9");
        } 
    /* if (data.record.master == true) {
        $('#PersonTableContainer').find(".jtable tbody tr td:eq(2)").css("background", "#F5ECCE");
                }  */
        }
}

参考

https://github.com/hikalkan/jtable/issues/1427#issuecomment-50030798

https://stackoverflow.com/questions/19486519/how-can-i-change-the-background-color-in-a-specific-row-of-jquery-jtable