[英]Unable to change background color of selected row in DataTable jQuery
[英]Change row background color pdf export dataTable
我需要檢查一列的值是否為負數以及在導出為 PDF 時,如果是,則使整個單元格變為紅色或 text-decoration: line-through。
但是我不知道如何訪問元素來進行這樣的修改。
我可以在瀏覽器中顯示背景時修改背景,但在導出時效果不同。
{
extend: 'pdfHtml5',
footer: true,
text: 'PDF',
header: true,
title: t,
orientation: 'landscape',
exportOptions: {
rows: function ( idx, data, node ) {
//node.attributes.style = {background-color: "#000";};
//console.log(node.attributes.style);
//return true;
// return data[2] === 'London' ?
// true : false;
}
},
customize: function(doc) {
doc.content.splice( 1, 0, {
margin: [ 0, 0, 0, 0 ],
alignment: 'center',
image: base64
} );
doc.defaultStyle.fontSize = 10;
doc.pageMargins = [20,10,10,10];
doc.styles.tableHeader.fontSize = 14;
doc.styles.title.fontSize = 12;
// Remove spaces around page title
doc.content[0].text = doc.content[0].text.trim();
}
},
{
extend: 'print',
footer: true,
}
],
fnRowCallback: function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var valor = aData[3].split('$');
//console.log(teste);
if (parseInt(valor[1])<0) {
$(nRow).css('background-color', '#e96464')
}else{
$(nRow).css('background-color', '#cdedc1')
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.