Restrict decimal places when editing Numeric cell type?

Tags: #<Tag:0x00007f8b2a138758> #<Tag:0x00007f8b2a1382a8>

Hi,

Is it possible to restrict the number of decimal places when editing Numeric cells?

I know it’s possible to use numericFormat to affect the “displayed value” after editing but we have some cases where we need to restrict the edit input to two decimal places to avoid potential rounding issues when calculating totals outside of HoT from the actual values stored in the backend.

Thanks.

Hi @blake.gilchrist

In this case it would most likely require to build a custom renderer and validator. First to be able to handle such restricted input, and the second one to be able to validate the inputted values. We don’t have any API that would let you achieve that out-of-the-box.

Here you can find guides about creating your custom editor: https://handsontable.com/docs/react-data-grid/cell-editor/#class-based-editors and validator: https://handsontable.com/docs/react-data-grid/cell-validator/

If you would encounter any issues during the implementation process, let me know.

Thanks @adrian.szymanski. I presumed that was probably the case but thanks for confirming.

No problem. I will close this topic for now, but as I mentioned, if you would need help with anything, feel free to open a new one.