layui数据表格根据某一格数据状态改变当前列字体颜色

开发中遇到需要根据返回的数据中的某一个字段的状态来改变当前行的字体颜色。

function planTitle(paramJson) {
            planTable = table.render({
                elem: '#plan-table',
                headers: {"_token": _token},
                url: zuulUrl,
                where: {
                    paramJson: paramJson
                },
                title: '生产计划数据表',
                cols: [[
                    {type: 'radio',fixed:'left'},//勾选框
                    {field: 'auditState', title: '审核状态',fixed:'left'},
                    {field: 'auditUserName', title: '审核人',fixed:'left'},
                    {field: 'makerUserTime', title: '制定时间',fixed:'left'}
                ]],
                //根据字段状态改变行字体颜色
                done: function () {
                    var index = -1;
                    $("[data-field='auditState']").children().each(function () {
                        index++;
                        if ($(this).text() === '已审核') {
                            $('tr').eq(index).css("color", '#00c600');
                        }
                    });
                },
                page: true,
                parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                    return {
                        "code": 0, //解析接口状态
                        "msg": res.message, //解析提示文本
                        "count": res.length, //解析数据长度
                        "data": list //解析数据列表
                    };
                },
                height: 'full-72',
            });
        }

代码参考地址:https://fly.layui.com/jie/31770/page/3/ @爷们无悔

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值