使用单元格编辑按下 Home/End 键的事件
Event on Home/End keys pressed using cell editing
使用 Ag-Grid 8.1.1(免费版)和 AngularJS1.5.8
我有一个可编辑的网格。
网格的默认行为是 Use home and end to go to the first and last rows.
(参见 https://www.ag-grid.com/javascript-grid-keyboard-navigation/?framework=angularjs)
我的问题是:在编辑单元格时,我按 End 键转到输入的末尾。然后网格向下滚动到最后一行。
如何覆盖此行为?
到目前为止我做了什么:
onCellEditingStarted: function(gridEvent) {
$($element).on('keydown.grid', function(jqueryEvent) {
jqueryEvent.stopPropagation();
jqueryEvent.preventDefault();
if (e.key === 'End') {
myCustomFunction();
}
});
},
myCustomFunction
被调用,但网格的默认行为不会被 e.stopPropagation(); e.preventDefault();
停止
最简单的答案是为您希望能够使用主页和结束按钮的每一列设置 cellEditor: 'popupText'
。这是演示该行为的 plnkr。我不确定这是否会被开发人员视为 bug/defect,但它至少适用于第 9 版。
使用 Ag-Grid 8.1.1(免费版)和 AngularJS1.5.8
我有一个可编辑的网格。
网格的默认行为是 Use home and end to go to the first and last rows.
(参见 https://www.ag-grid.com/javascript-grid-keyboard-navigation/?framework=angularjs)
我的问题是:在编辑单元格时,我按 End 键转到输入的末尾。然后网格向下滚动到最后一行。
如何覆盖此行为?
到目前为止我做了什么:
onCellEditingStarted: function(gridEvent) {
$($element).on('keydown.grid', function(jqueryEvent) {
jqueryEvent.stopPropagation();
jqueryEvent.preventDefault();
if (e.key === 'End') {
myCustomFunction();
}
});
},
myCustomFunction
被调用,但网格的默认行为不会被 e.stopPropagation(); e.preventDefault();
最简单的答案是为您希望能够使用主页和结束按钮的每一列设置 cellEditor: 'popupText'
。这是演示该行为的 plnkr。我不确定这是否会被开发人员视为 bug/defect,但它至少适用于第 9 版。