我使用 Tabulator JS,并且有 2 列包含数字数据。首先,我使用了带有 formatterParams 参数的内置 money 格式化程序,对于第二个,我想应用完全相同的、具有相同参数的,但还要添加,例如,单元格的颜色。如何以自定义格式应用formatterParams?
new Tabulator("#data-table", {
data: data,
layout: "fitColumns",
columns: [{
title: "Length",
field: "length",
formatter: zeroValueFormatter,
formatterParams: {
thousand: " ",
precision: false
}
},
{
title: "New length",
field: "newLength",
formatter: "money",
formatterParams: {
thousand: " ",
precision: false
}
],
});
function zeroValueFormatter(cell, formatterParams /* ? */) {
if (cell.getValue() === 0) {
cell.getElement().style.backgroundColor = "#add8e6";
}
return cell.getValue();
} Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号