繁体   English   中英

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

[英]How do I set the focus on the first editable cell in a row onRowClicked?

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

我可以获取 rowIndex,但无法获取列集合来查看属性。 我想保留 rowIndex,但获取第一个可编辑列并将焦点设置在那里。 (现在,它是偶然选择来触发事件的任何东西。)

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

我试过查看这里生成的对象:

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

这给了我一个事件,我可以在其中获取 rowIndex 和 columnApi。 我希望这里的某个地方有一个集合来执行 for 循环,但我没有看到。

你可以在你的onRowEditingStarted做类似的onRowEditingStarted

// scrolls to the first column, or first editable column. you can pass in the correct index
var firstEditCol = params.columnApi.getAllDisplayedColumns()[0];
/////
params.api.ensureColumnVisible(firstEditCol );

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

这个来自 docs 的例子是一个很好的起点

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM