Hi
It sounds like you're encountering an issue where the rounding appears correct when logged, but the values lose their formatting when passed into the HTML template. Here are a few potential causes and solutions for this issue:
1.
Ensure Consistent Formatting: Even though you round the number using `Math.round()`, it's a good practice to ensure the formatted value is consistently used in your script. Check that the `testResult` variable is the one being passed into the HTML template and not `rowData[3]` directly.
2.
Check Data Type Conversion: Since you are using `.toString(0)`, it should normally just convert the rounded number to a string without any decimals. If it’s still showing decimals, it might be that somewhere else in your script the rounding isn't applied, or the wrong variable is being sent to the template.
3.
Template Rendering Issues: Sometimes, the way variables are injected into the HTML template might cause them to revert to their original format or undergo unexpected conversions. Make sure that the data binding or interpolation method used in the template accurately reflects the formatted string.
4.
Force Formatting in HTML: If you want to ensure no mistakes in the HTML rendering, you can also handle the rounding directly in the HTML template, if your template engine supports it. This is less clean as logic should ideally be separated from presentation, but it is a fallback.
Here is a refined approach to make sure your number is rounded and converted to a string correctly:
var roundedValue = Math.round(rowData[3]);
var testResult = roundedValue.toString();
And ensure that `testResult` is the variable being interpolated into your HTML template.
If you continue to face issues, please provide more details about how you are passing data into the HTML template so I can give more targeted advice.