setDataAtCell - if I want to cet data after event keyDown, I always get an error, which means that the cell is not being updated alone

Tags: #<Tag:0x00007f8b25d35510>

When I do this with first cell, everything is fine, with the second - two are updated - the first and the second. If with third - then three. Despite the fact that I always select one cell at a time and I want that setDataAtCell to be applied one at the time. Is it possible?

const afterBeginEditing = (row: number, col: number) => {
document.addEventListener(“keydown”, e => {
const str = e.ctrlKey;
const punkt = e.key;
if (str && punkt === ‘.’) {
const today = new Date();
const date = ${today.getDate()}.${today.getMonth()+1}.${today.getFullYear()};
table.value.hotInstance?.setDataAtCell(row, col, date, ‘edit’);
}
})
}

Hi @tanyasofy

I am not familiar with the syntax that you used for constructing the date so I used plain JavaScript here https://jsfiddle.net/q9mdr54L/3/ and it seems to work well, so maybe that’s the reason.

What I do here

  1. Select a cell
  2. Click Enter
  3. Click and hold Control, then press a dot .

and the editor is closed, and we have a new value in the cell, which is today’s date.

I tested it on latest Chrome on macOS Monterey.

Thank for your answer.It dosnt work by me. I work with electron and DB mssql. Incredible things happen with setDataAtCell :slight_smile:

Oh, I see. I’ve created a simple project using Electron, but that was around Handsontable v8 or v9. you can maybe try to add a delay (with the setTomeout()) to the setDataAtCell(). Or try to close the editor first and then use the setDataAtCell().

All data that i have changed since the opening og the app changes to my date that i want to put in just one cell. Should i close editor? if so, then how?

I’m just guessing here as it works in the vanilla but doesn’t in the Electron. You can try the getActiveEditor() and getCellEditor() I’m not sure which one would be better for Electron, but the getActiveEditor() exposes the close() method that you can use.

1 Like