Layui 數據表格特定數據行變色


前言:

        1、個人轉碼小說網站:友書-綠色、純凈、無廣告,歡迎廣大小說閱讀愛好者同行來本網站看小說

        2、書友交流群:580462139(群主及管理均為資深90后程序猿,也歡迎諸位剛畢業的小白入群咨詢編程、面試、就業等各方面問題哦)

        3、對外承接app API開發、網站建設、系統開發,聯系方式於文章最下方

前端樣式界面截圖:

 

前端代碼:

//方法級渲染
            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);
                    }
                }
            });

注解:

done:數據渲染完的回調

parseData-拿取原始數據

 

文檔截圖:

  1、parseData:

 

2、done:

 

 原文:https://blog.csdn.net/m0_37781450/article/details/103908272


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM