Issue trying to change cell value when opening editor

Tags: #<Tag:0x00007f24a11d6358>

Hi there. I am trying to change the value of a cell when the user opens the editor for a cell but when trying to set it the editor closes on its own.

My problem: I have columns where the cells are percentages so when they are not being edited they show as 5%, 10%, 55%, etc but when they go to edit the value of the cell it shows as .05, .1, .55 instead. In general this is correct but they want it to show the whole number that they see as a percent instead of the decimal value. I already have it so that after they are done editing it saves their whole number correctly as a percent/decimal but I am having trouble when they initially load the cell editor as my current solution to try and use setDataAtCell closes the editor right after its opened. Please advise. We use a licensed version of HOT V8.3.2

Solved the issue using the method below since I was, for some reason, unable to hit the custom editor I tried adding:

I used 2 hooks, 1 for “afterBeginEditing” and the other “beforeChange”.

In the first hook I get the cells value using: let value = hot.getDataAtCell(row, col);
I then set the value to itself * 100 and set the value for the editor (which is shown to the user) by using: hot.getActiveEditor()?.setValue(value).

This then renders correctly for the user. Once they are done editing, the second hook is called and I proceed to divide the newly entered value by 100 and set the value using r[3] = value; this part is done inside the forEach statement of the cellChanges[] where r is an element from that array

Hi @rostamijonathan,
I’m glad you solved the problem and shared the solution. That might help others to solve similar problems.
Thank you for your involvement in building Handsontable’s community.