[英]How Can I Change Background Color of Row based on cell value in Datatable?
[英]Why not Change Row background color based on cell value DataTable in jquery(java spring)?
我正在尝试在我的 jsp 页面中创建一个数据表。 有对控制器的调用并返回响应 json。 但是这里我根据单元格值更改数据表行的颜色。 但是没有用。
数据表。
oTable = $("#dataTable").dataTable({
"bServerSide" : true,
"sAjaxSource" : "${baseURL}/ReviewAlert/GetReviewAlert",
"bProcessing" : true,
"sPaginationType" : "full_numbers",
"bJQueryUI" : true,
"iDisplayLength": 15,
"aLengthMenu": [[15, 20, 30, 50], [15, 20, 30, 50]],
"createdRow": function( row, data, dataIndex ) {
if ( data[3]-currDate<0) {
$(row).addClass('red');
}
} ,
"aoColumns" : [ {
"mDataProp" : "serialNumber",
"bSearchable" : false,
"bVisible" : false
},{
"mDataProp" : "aNumber"
},{
"mDataProp" : "aName"
}, {
"mDataProp" : "reviewDate"
},{
"mDataProp" : "reviewTitle"
},{
"mData" : null,
"sTitle": "Action",
"bSearchable": false,
"bSortable": false,
"sClass" : "alignCenter",
"fnRender": function(obj) {
var action="<input id='btnRvwView' type='button' title='View/Edit' class='button_view'></input>";
return action;
}
}]
});
和我的CSS。
.red {background-color: red !important;}
使用以下 CSS 规则覆盖 DataTables 单元格样式。
.red td { background-color: red !important; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.