diff --git a/frontend/src/Editor/Components/Table/columns/index.jsx b/frontend/src/Editor/Components/Table/columns/index.jsx index a9e8391cde..ce53afe9a4 100644 --- a/frontend/src/Editor/Components/Table/columns/index.jsx +++ b/frontend/src/Editor/Components/Table/columns/index.jsx @@ -258,6 +258,21 @@ export default function generateColumnsData({ color: textColor ?? '', overflow: 'hidden', }; + + const allowedDecimalPlaces = column?.decimalPlaces ?? null; + + const removingExcessDecimalPlaces = (cellValue, allowedDecimalPlaces) => { + allowedDecimalPlaces = resolveReferences(allowedDecimalPlaces); + if (cellValue?.toString()?.includes('.')) { + const splittedCellValue = cellValue?.toString()?.split('.'); + const decimalPlacesUnderLimit = splittedCellValue[1].split('').splice(0, allowedDecimalPlaces).join(''); + cellValue = Number(`${splittedCellValue[0]}.${decimalPlacesUnderLimit}`); + } + return cellValue; + }; + + cellValue = allowedDecimalPlaces ? removingExcessDecimalPlaces(cellValue, allowedDecimalPlaces) : cellValue; + if (isEditable) { const validationData = validateWidget({ validationObject: { @@ -301,23 +316,6 @@ export default function generateColumnsData({ } }; - const allowedDecimalPlaces = column?.decimalPlaces ?? null; - const removingExcessDecimalPlaces = (cellValue, allowedDecimalPlaces) => { - allowedDecimalPlaces = resolveReferences(allowedDecimalPlaces); - if (cellValue?.toString()?.includes('.')) { - const splittedCellValue = cellValue?.toString()?.split('.'); - const decimalPlacesUnderLimit = splittedCellValue[1] - .split('') - .splice(0, allowedDecimalPlaces) - .join(''); - cellValue = Number(`${splittedCellValue[0]}.${decimalPlacesUnderLimit}`); - } - return cellValue; - }; - cellValue = allowedDecimalPlaces - ? removingExcessDecimalPlaces(cellValue, allowedDecimalPlaces) - : cellValue; - return (