【发布时间】:2017-09-05 07:35:59
【问题描述】:
使用 Ag-Grid 8.1.1(免费版)和 AngularJS 1.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();阻止
【问题讨论】:
-
你试过
event.stopPropagation(); event.preventDefault();而不是e.stopPropagation(); e.preventDefault();吗? -
@akash
event不是 JQuery 事件,而是 ag-grid 事件。它是这样构建的{node: RowNode, data: Object, value: "Nombre", rowIndex: 1, column: Column…}。我在代码中更改了名称。
标签: javascript angularjs ag-grid