関数を使用してHandsOnTableセルの背景を変更すると、セルにレンダリングされた値が小数点以下1桁に変更されます。私は誤って書式文字列を削除したためだと思いましたが、それは間違っているようです。レンダラーを使用するとHandsOnTableセルの値が変化する
これは、レンダラ、細胞機能および列の定義である:
function negativeValueRenderer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
if (value !== instance.getData()[row][2])
td.style.background = 'yellow';
}
Handsontable.renderers.registerRenderer('negativeValueRenderer', negativeValueRenderer);
function cells(row, col, prop) {
if (col === 1)
return { format: '0.00', renderer: negativeValueRenderer }
else
return { format: '0.00', }
}
var colDefs = [
{
dateFormat: 'DD/MM/YYYY HH:mm',
correctFormat: true,
width: 150,
editor: false,
disableVisualSelection: true,
readOnly: true,
}, {
type: 'numeric',
format: '0.00',
width: 75
}, {
type: 'numeric',
format: '0.00',
width: 75,
editor: false,
readOnly: true,
}
];
は、どのように私は持っている細胞、例えば、1254.23で小数第2位を維持していることを確認することができます - 私のテーブルには3列目は2でレンダリングされます小数点以下桁数は1桁です。