我有一个可编辑的网格。两个列是ItemCode和Quantity。当用户输入数量并按下向下键时,我希望下一行将焦点置于下一行的ItemCode单元格上。我添加了这个事件监听器,它会转到单元格,但它会快速闪烁进入编辑模式,然后进入选定模式。我如何确保单元格保持编辑模式?Angular UI Grid在导航上将焦点设置到单元格
gridApi.cellNav.on.navigate($scope, function (newRowcol, oldRowCol) {
$scope.$broadcast('uiGridEventEndCellEdit');
if (oldRowCol != null &&
oldRowCol.col.colDef.name == 'quantity' &&
oldRowCol.row != newRowcol.row) {
newRowcol.row.grid.api.cellNav
.scrollToFocus(newRowcol.row.entity,
newRowcol.row.grid.options.columnDefs[1]);
}
});
UPDATE:这是我的columnDefs:
$scope.gridOptions.columnDefs = [
{
name: 'itemCode',
displayName: 'Part #',
editableCellTemplate: $scope.itemCodeEditableTemplate,
width: 150,
cellTooltip: function (row, col) {
return row.entity.itemCode
}
},
{
name: 'quantity', displayName: 'Qty', type: 'number', width: 60,
cellTooltip: function (row, col) {
return row.entity.quantity
}
}
]
我相信这是一个角度UI网格的错误。当我将它作为一个bug提出时,它被关闭了,没有解决问题的细节。请参阅https://github.com/angular-ui/ui-grid/issues/4812和我的SO帖子http://stackoverflow.com/questions/33991169/scrolltofocus-to-cell-with-enablecelleditonfocus-true-does -not-make-the-cell-edi –
我有一个解决方法,它适用于我希望跳转到下一行的字段时使用特定值标记过某个单元格的情况,但是我意识到它不适用于你的情况下,你正在使用向下键移动。基本上,它涉及在列定义中使用enableCellEdit:false创建假间隔列。如果您可以要求用户在单元格之间制作标签,请发布您的列定义,我可以将解决方法分享为可能的答案。 –
好的。感谢您的答复。我要去尝试https://www.ag-grid.com/,看看这是怎么回事,因为我已经有了一个针对typeahead的UI-Grid的工作方式等等。我将要结束工作到处都是。如果ag-grid无效,那么我会问你的解决方法 – Asagohan