Navigation 如何聚焦到AG网格行组件以使用键盘导航

Navigation 如何聚焦到AG网格行组件以使用键盘导航,navigation,keyboard,focus,ag-grid,Navigation,Keyboard,Focus,Ag Grid,如果我关注除Ag Grid行以外的元素,则Ag Grid的键盘导航不起作用 为了解决这个问题,我需要在执行按钮单击后重新聚焦到Ag网格行元素 我尝试了以下方法来聚焦ag网格行,但仍然不起作用 this.elElement.nativeElement.querySelectorAll('.ag-row').attr('tabindex', -1).focus(); 在执行按钮单击后,我应该能够聚焦回AG网格,以便在AG网格中使用键盘导航您可以使用AG网格的setFocusedCell()api聚

如果我关注除Ag Grid行以外的元素,则Ag Grid的键盘导航不起作用

为了解决这个问题,我需要在执行按钮单击后重新聚焦到Ag网格行元素

我尝试了以下方法来聚焦ag网格行,但仍然不起作用

this.elElement.nativeElement.querySelectorAll('.ag-row').attr('tabindex', -1).focus();

在执行按钮单击后,我应该能够聚焦回AG网格,以便在AG网格中使用键盘导航

您可以使用AG网格的
setFocusedCell()
api聚焦单元格

// scrolls to the first row
gridOptions.api.ensureIndexVisible(0);

// scrolls to the first column
var firstCol = gridOptions.columnApi.getAllDisplayedColumns()[0];
gridOptions.api.ensureColumnVisible(firstCol);

// sets focus into the first grid cell
gridOptions.api.setFocusedCell(0, firstCol);
请阅读此处文档中的更多内容-和