【问题标题】:How to focus to AG-Grid row component to use the keyboard navigation如何聚焦到 AG-Grid 行组件以使用键盘导航
【发布时间】:2019-05-08 06:59:03
【问题描述】:

如果我专注于 Ag-Grid 行以外的元素,则 Ag-Grid 的键盘导航不起作用。

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

我尝试了以下方法来关注 ag-grid 行但仍然无法正常工作

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

单击按钮后,我应该能够将注意力重新集中到 AG-Grid 上,以便在 Ag-Grid 中使用键盘导航

【问题讨论】:

    标签: navigation keyboard focus ag-grid


    【解决方案1】:

    您可以使用 ag-grid 的 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);
    

    在此处阅读更多文档 - https://www.ag-grid.com/javascript-grid-api/#navigationhttps://www.ag-grid.com/javascript-grid-keyboard-navigation/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多