I set up an afterOnCellMouseDown event and there are bunch of things I need to do after a cell is clicked.
I wanted to find out if there is a way to trigger a click event on a cell in handsontable?
I know there is a way to select a row or a column, but I specifically need to trigger a click event so that my afterOnCellMouseDown will be triggered.
Any ideas?
Thanks!
Piotr from the Handsontable team helped me out on this issue. He prepared the demo Here is a link - https://jsfiddle.net/mfhqz69L/
You need to know that handsontable can't listen to click because the click is fired after a full click action occurs; that is, the mouse button is pressed and released while the pointer remains inside the same element. mousedown is fired the moment the button is initially pressed. This is a link to full documentation - https://developer.mozilla.org/en-US/docs/Web/API/Element/mousedown_event
var hot = new Handsontable(hotElement, hotSettings);
function triggerMouseEvent(type, target) {
const event = document.createEvent('MouseEvent');
event.initMouseEvent('mousedown', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
target.dispatchEvent(event);
}
var hotCell = hot.getCell(0, 0);
triggerMouseEvent('mousedown', hotCell);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With