When using the onRowDataBound event, how can I set the font color for this row, not the background color?
/**
* 设置行样式
*/
function onRowDataBound(args) {
const row = args.data;
// 检查 row.Avail 是否为 false,设置行颜色为蓝色
if (typeof row.Avail !== 'undefined' && row.Avail === false) {
args.row.classList.add('blue-row');
}
// 检查 row.BillState 是否等于 -1,设置行颜色为蓝色
if (typeof row.BillState !== 'undefined' && row.BillState === -1) {
args.row.classList.add('blue-row');
}
// 检查 row.RedWord,根据其值设置行颜色
if (typeof row.RedWord !== 'undefined') {
if (row.RedWord === 1) {
args.row.classList.add('blue-row');
} else if (row.RedWord === 2) {
//args.row.style.color = 'red';
args.row.classList.add('red-row');
}
}
// 如果没有 'seq' 列,跳过序号设置逻辑
if (!state.hasSeqColumn) return;
if (args.row) {
var rowIndex = parseInt(args.row.getAttribute('aria-rowIndex'));
var currentPageNumber = GGrid.value.ej2Instances.pageSettings.currentPage;
var pageSize = GGrid.value.ej2Instances.pageSettings.pageSize;
var startIndex = (currentPageNumber - 1) * pageSize;
args.row.querySelector('.e-rowcell').innerHTML = (startIndex + rowIndex).toString();
}
}
<style>
.blue-row {
background-color: rgba(173, 216, 230, 0.5); /* 柔和的浅蓝色 */
}
.red-row {
background-color: rgba(255, 182, 193, 0.5); /* 柔和的浅红色 */
}
</style>