layui table指定行变色 改变样式

done: function(res, curr, count){
    //进行表头样式设置
    $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'orange','background':'linear-gradient(#f2f2f2,#cfcfcf)'});
    //遍历各行 处理样式等
    for(var i in res.data){
        //获取当前行数据
        var item = res.data[i];
        //如:ID等于1则复选框禁止选择
        if(item.id==1){
            $('tr[data-index=' + i + '] input[type="checkbox"]').prop('disabled', true); //禁用当前
            $('tr[data-index=' + i + '] input[type="checkbox"]').parent('div').css('display', 'none'); //隐藏这个复选框
            table.render('checkbox'); // 重新渲染一下checkbox
        }
        // 02.如果已结算则整行变灰色
        if(item.ck23=='ok'){
            $("tr[data-index='" + i + "']").attr({"style":"background:#cccccc"});
        }
        // …… 其他功能
    }
}

Tags: 前端

添加新评论