I am trying to create a data table in my jsp page. There is call to controller and return a response json. But here iam change color of datatable row based on cell value. But didnt work.
data table.
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;
}
}]
});
and my css.
.red {background-color: red !important;}
使用以下 CSS 规则覆盖 DataTables 单元格样式。
.red td { background-color: red !important; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.