When I use a function to change the background of a HandsOnTable cell, the value rendered in the cell changes to 1 decimal place. I thought this was because I was inadvertently removing the format string, but that appears to be incorrect.
This is the renderer, cell function and column definition:
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,
}
];
How can I ensure that cells which have, eg, 1254.23 retain the two decimal places - in my table the third column is rendered with 2 decimal places but the second is with only 1 place.