I am working with a kendo react grid, and i need to implement to open a menu by right clicking on any cell. By using onContextMenu on the cell render, I am able to open a popup:
cellRender(tdElement, cellProps) {
const dataItem = cellProps.dataItem;
const field = cellProps.field;
const additionalProps = (cellProps.dataItem[this.editFieldName] && (cellProps.field === cellProps.dataItem[this.editFieldName])) ?
{
ref: (td) => {
const input = td && td.querySelector('input');
if (!input || (input === document.activeElement)) { return; }
if (input.type === 'checkbox') {
input.focus();
} else {
input.select();
}
}
} : {
onClick: () => { this.enterEdit(dataItem, field); },
onContextMenu: (e) => { e.preventDefault(); this.onContextMenu(e, dataItem, field); }
};
return React.cloneElement(tdElement, { ...tdElement.props, ...additionalProps }, tdElement.props.children);
}
...
Is it possible for a Popup to detect that it has lost the focus, and then set show property to false ?
Best regards.
PS: Maybe there is a better solution to implement a context menu ?