编程带来专注于排在第一位NG网排在、专注于、NG

2023-09-13 04:53:06 作者:多余

在我的项目,我有一个要求,尽快把重点放在NG-网格的第一行电网负荷,当我preSS向下键就应该移动到下一行。我加了以下事件:

In my project, I have a requirement to bring focus on first row of ng-grid as soon as the grid loads and it should move to next row when I press the down key. I added the following event:

$scope.$on('ngGridEventData', function (e,s) {
    $scope.gridOptions.selectRow(0, true);
});

不过,此事件只是选择第一行,它并不需要把重点放在第一行。行需要点击获取焦点那里。那是什么额外的发言中,我们需要编写获取焦点呢?

But this event just selects the first row, it doesn't take the focus on first row. The row needs to be clicked to get the focus there. What is that additional statement we need to write to get the focus there?

推荐答案

我报道它NG-电网GitHub的回购和得到了解决。你可以在这里检查的对话:https://github.com/angular-ui/ng-grid/issues/539

I reported it on github repo of ng-grid and got the solution. You can check the conversation here: https://github.com/angular-ui/ng-grid/issues/539

我们需要添加以下语句把焦点转移到选定的元素:

We need to add the following statement to bring focus to the selected element:

$(".ngViewport").focus();