I want to have a button at the end of my Table where i can Click and open the rowContextMenu below the Button.
But i also want it to pop up when I rightclick anywhere on the row.
I already tried a few things
var menuButtonFormatter = (cell: any) => {
var menuBtn = document.createElement('button');
menuBtn.type = 'button';
menuBtn.innerHTML = '<span class="material-icons" style="color: #707070">more_horiz</span>';
menuBtn.classList.add('menu-button');
menuBtn.addEventListener('click', (event) => {
event.stopImmediatePropagation();
const myEvent: any = new Event('row-contextmenu');
myEvent.pageX = event.pageX;
myEvent.pageY = event.pageY;
cell.getRow().getElement().dispatchEvent(myEvent);
});
buttonHolder.appendChild(menuBtn);
return buttonHolder;
}
This is the Button
And my Column looks like this:
{
title: this.$t('actions'),
field: 'actions',
// formatterParams: poParams,
formatter:menuButtonFormatter,
headerSort: false,
width: 110,
frozen: true,
}
I tried many different Things but nothing would work.
I also tried const myEvent: any = new Event('contextmenu');
as the button Event but it also did nothing. Also nothing showed up in the Console