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
分类:
前端问题
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库