Search code examples
handsontable

Dynamically edited cell value in Handsontable is empty


I apologize if my question was already answered but I didn’t find any relevant answer. I would like to dynamically edit cell value therefore I used:

var setButton = document.getElementById('setButton');
setButton.addEventListener('click', function(event) {        
    hot.getActiveEditor().beginEditing();
    hot.render();
})

it edits cell but I don’t see original value, only empty.

Example:

https://jsfiddle.net/janzitniak/qdg420v8/6/

Note: Please select to any cell and then click to Set value to selected cell button.

Thank you for any help.


Solution

  • Solution

    Long story short: Call enableFullEditMode() before you call beginEditing().
    Not sure about the render() call though - I think that call can be removed.

    JSFiddle

    Storytime

    I was looking for a solution to a similar problem, and had to look into the code to figure it out. In hindsight this was straightforward.

    • First there is some code which will reset the content of textareas to an empty string, to work with IME (or at least the comment says so)
    • And then there is code which will only set the original value into the cell, when the full editor mode is enabled.