如何将焦点设置在onRowClicked行的第一个可编辑单元格上?

时间:2019-02-05 16:46:01

标签: javascript ag-grid

我有一个ag-grid,我需要能够通过键盘进行编辑。我将editType设置为fullRow,我希望能够添加JavaScript,这样当我触发onRowEditingStarted事件时,它会转到第一个可编辑的单元格,因为有时我的网格大于屏幕。

我可以获取rowIndex,但是我无法保留列集合以查看属性。我想保留rowIndex,但获取第一个可编辑的列并在那里设置焦点。 (现在,可以随意选择触发该事件。)

有人有我可以看的例子吗?

我尝试浏览这里产生的对象:

onRowEditingStarted: function(params) {
   console.log("started row editing");
   console.log(params);
}

这给了我一个事件,可以获取rowIndex和columnApi。我希望这里的某个地方有一个集合可以进行for循环,但是我看不到。

1 个答案:

答案 0 :(得分:0)

您可以在onRowEditingStarted

中执行类似的操作
// scrolls to the first column, or first editable column. you can pass in the correct index
var firstEditCol = params.columnApi.getAllDisplayedColumns()[0];
paras.api.ensureColumnVisible(firstEditCol );

// sets focus into the first grid cell
params.api.setFocusedCell(params.rowIndex, firstEditCol);  

文档中的example是一个很好的起点

相关问题