将焦点设置到 ui-grid 中新添加的行
Set focus to newly added row in ui-grid
我正在使用 ui-网格。用例是在单击按钮时添加新行。我想将焦点放在新添加行的第一个单元格上关于如何做的任何建议?这是相同的 plunkr
。
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-网格。用例是在单击按钮时添加新行。我想将焦点放在新添加行的第一个单元格上关于如何做的任何建议?这是相同的 plunkr
。
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]
);
});
希望对您有所帮助。