layuiTable根据返回的JSON内容改变指定行的颜色
1 // 渲染表格 2 var insTb = table.render({ 3 elem: '#tableArticles', 4 //url: '../../json/loginRecord.json', 5 url: '{:url('hospital/index')}', 6 limit: 10, 7 page: true, 8 cellMinWidth: 100, 9 title: '预约列表', 10 cols: [[ 11 {field:'name',title: '姓名',width:80,align: 'center'}, 12 {field:'sex',title: '性别',width:60,align: 'center'}, 13 {field:'old', title: '年龄',width:60,align: 'center'}, 14 {field:'tel', title: '电话',width:120,align: 'center'}, 15 {field:'address', title: '地址',width:100,align: 'center'}, 16 {field:'m_type', title: '病患类型',align: 'center'}, 17 {field:'doctor_num', title: '专家号',width:80,align: 'center'}, 18 {field:'doctor', sort: true,title: '专家'}, 19 {field:'con',title: '咨询内容'}, 20 { 21 field: 'status', align: 'center',width:80, templet: function (d) { 22 var strs = ['等待','已到诊']; 23 return strs[d.status]; 24 }, title: '状态' 25 }, 26 {field:'view_time',title: '预约时间'}, 27 {field:'depart',title: '部门'}, 28 {field:'media',title: '媒体'}, 29 {field:'service',title: '客服'}, 30 {field:'jjbs',title: '竞价标识'}, 31 {align:'center', toolbar: '#tableBarArticles', title: '操作', minWidth: 160,fixed: 'right'} 32 ]], 33 done: function (response) { 34 //定位当前table视图 35 var tableView = this.elem.next(); 36 //response.data获取后端返回的JSON格式数据 37 $.each(response.data,function (index,item) { 38 //逻辑判断 39 if(item.status == "1"){ 40 //改变TR标签内字体颜色 41 tableView.find('tbody tr[data-index="'+ index +'"]').css('color','red'); 42 } 43 }) 44 } 45 });