将焦点设置为ui-grid中新添加的行 [英] Set focus to newly added row in ui-grid
本文介绍了将焦点设置为ui-grid中新添加的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ui-grid.用例是在单击按钮时添加了新行.我想将重点放在新添加的行的第一个单元格上,有关如何执行操作的任何建议?这是相同的 plunkr
.
http://plnkr.co/edit/6zyZ5q
I am using ui-grid. The use-case is such that on clicking a button, a new row is added. I want to set focus on the first cell of the newly added row Any suggestions on how to do it ? Here's a plunkr
for the same.
http://plnkr.co/edit/6zyZ5q
$scope.addNew = function() {
var newobj = {"id": "","name":"" };
$scope.gridOptions.data.unshift(newobj);
$scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ROW);
//set focus to the new row
$scope.gridApi.cellNav.scrollToFocus( $scope.gridOptions.data[0], $scope.gridOptions.columnDefs[0]);
};
推荐答案
$timeout(function() {
$scope.gridApi.cellNav.scrollToFocus(
$scope.termGridOptions.data[0],
$scope.termGridOptions.columnDefs[0]
);
});
希望对您有帮助.
这篇关于将焦点设置为ui-grid中新添加的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文