Tweaking a bit the gridContextMenu function as follows achieves focusing of the ContextMenu and then refocusing the Grid when the ContextMenu is closed
function
gridContextMenu(gridEl, event) {
// some other code here....
if
(event.which == 3) {
if
($(event.target).closest(
"td"
).prop(
"class"
) ==
"rgActiveCell rgSelectedCell"
) {
menu.show(event);
}
}
else
{
var
menuX = $(cell).position().left + $(cell).width() / 2;
var
menuY = $(cell).position().top + $(cell).height() / 2;
menu.showAt(menuX, menuY);
// START focus the context menu and refocus grid when hiding
var
item = menu.get_items().getItem(0);
item.get_element().firstElementChild.focus()
menu.add_hidden(
function
() { gridEl.focus() });
// END focus the context menu and refocus grid when hiding
}
}