Layui数据表格整行变色

有时候要做数据判断,就需要对一些数据异常的数据整行变色,就会醒目很多,代码如下,核心就是数据渲染完成的回调里面那一段

table.render({
                elem: '#bindTableData'
                , method: 'post'
                , url: '这里是请求地址'
                , where: { accessToken: accessToken, type: 'all' }
                , toolbar: '#toolbarDemo'
                , cols: [[
                    { checkbox: true, fixed: true, field: 'Id', width: '4%' }
                    , { field: 'ComplaintNo', title: '投诉编号', width: '9%', align: 'center' }
                    , { field: 'ComplaintPatient', title: '投 诉 人', width: '6%', align: 'center' }
                    , { field: 'Relation', title: '患者关系', width: '6%', align: 'center' }
                    , { field: 'Contact', title: '联系电话', width: '7%', align: 'center' }
                    , { field: 'ComplaintSource', title: '投诉来源', width: '6%', align: 'center' }
                    , { field: 'ComplaintLevel', title: '投诉级别', width: '6%', align: 'center' }
                    , { field: 'Department', title: '被投诉科室', align: 'center' }
                    , { field: 'Complainant', title: '被投诉人', width: '6%', align: 'center' }
                    , { field: 'ReceptionDepartment', title: '接待科室', width: '10%', align: 'center' }
                    , { field: 'RegistDate', title: '投诉日期', width: '7%', align: 'center' }
                    , { field: 'Contents', title: '投诉内容', width: '11%', align: 'center' }
                    , { field: 'Address', title: '投诉状态', width: '6%', align: 'center' }
                    , { field: 'score', title: '操作', width: '10%', align: 'center', toolbar: '#barDemo' }
                ]]
                , id: 'TableReload'
                , page: true
                , done: function (res, curr, count) {
                    var that = this.elem.next();
                    res.data.forEach(function (item, index) {
                        if (item.ComplaintLevel === "严重") {
                            var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']");
                            tr.css("background-color", "#FF5722");
                            tr.css("color", "white");
                        }
                    });
                }, parseData: function (res) {
                    if (res.code == -1) {
                        layuiHelp.AlertMsg(res.msg, res.icon);
                    }
                }
            });

 

 

参考来源:https://blog.csdn.net/m0_37781450/article/details/103908272

posted @ 2022-11-16 17:41  Core、陈  阅读(1575)  评论(0)    收藏  举报