我需要创建一个 jQuery 数据表,其中某些行可能具有灰色背景色——这意味着它们已被禁用。仅当相应 MySQL 表的“状态”列等于 0 时,行才能具有灰色背景。
看看下面的代码。'10' 列被隐藏。它包含status
价值。如果为 0,则该行应具有不同的背景颜色。但这不起作用。没有错误信息。有任何想法吗?
$(document).ready(function(){
$('#newspaper-b').dataTable({
"sPaginationType":"full_numbers",
"aaSorting":[[4, "asc"]],
"aoColumns": [null,null,null,null,null,null,null,null,null,null,
{"bSearchable": true, "bVisible": false},null,null],
"bJQueryUI":true,
'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
if(aData[10]=="0"){
nRow.className = "disactivatedRow";
}
return nRow;
}
});
CSS
.disactivatedRow td {
background-color:#ffbba9 !important;
color: #e6e6fa;
}
#newspaper-b {
border-collapse: collapse;
border-color: #B7DDF2;
border-style: solid;
border-width: 1px;
font-family: Arial,Helvetica,sans-serif;
font-size: 11px;
margin: 0;
text-align: left;
width: 480px;
}
#newspaper-b th {
background: none repeat scroll 0 0 #EBF4FB;
border-color: lightgray;
font-size: 11px;
font-weight: bold;
padding: 15px 10px 10px;
}
#newspaper-b tbody tr td {
background: none repeat scroll 0 0 #FFFFFF;
}
#newspaper-b td {
border-top: 1px dashed #FFFFFF;
color: #000000;
padding: 10px;
}
#newspaper-b tbody tr:hover td {
background: none repeat scroll 0 0 #FFCF8B;
color: #000000;
}
#newspaper-b tbody tr.selected td {
background: none repeat scroll 0 0 #FFCF8B;
color: #000000;
}