1.依据存入数据判断
"createdRow": function (row, data, index) {
debugger;
if (index > 0){ //判断要操作行
for (var i = 4; i<row.cells.length; i++){ //从第4列开始操作
if (row.cells[i].textContent == '-' && i>4){ //依据返回值给单元格上色
$(row).children('td').eq(i-1).attr('style',' background-color: #d6c77c;');
return;
}else {
if (row.cells[i-1].textContent != '-'){
$(row).children('td').eq(i).attr('style',' background-color: #51ba6f;');
}
}
}
}
},
2.依据数据日期处理
"createdRow": function (row, data, index) {
if (index > 0){
var dataDate = new Date(data.date).getTime();
var now = new Date(getNextDate(new Date())).getTime();
var days = (now - dataDate)/(1000 * 3600 * 24);
var red = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,29,59,89];
for (var i = 4; i<row.cells.length; i++){
if (days < red[i-4]){
row.cells[i].textContent = '-';
}else if (days == red[i-4]){
$(row).children('td').eq(i).attr('style',' background-color: #d6c77c;');
}else {
$(row).children('td').eq(i).attr('style',' background-color: #51ba6f;');
}
}
}
},