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 @   Core、陈  阅读(1429)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示