scroll to focus is not working on newly added row
after adding a new row, I am trying to set focus to the first row and the first column, but it doesn't work.
$scope.gridApi.cellNav.scrollToFocus( $scope.gridOptions.data[0], $scope.gridOptions.columnDefs[0]);
here is a plunker for the same http://plnkr.co/edit/6zyZ5q?p=preview
But if you point to index 1, instead of pointing to index 0, it works again. I guess it is a bug
$scope.gridApi.cellNav.scrollToFocus( $scope.termGridOptions.data[1], $scope.termGridOptions.columnDefs[0]);
termGridOptions is undefined. Also use a timeout so that ui-grid can process the change first.
$timeout(function() {
$scope.gridApi.cellNav.scrollToFocus( $scope.gridOptions.data[0], $scope.gridOptions.columnDefs[0]);
}, 100);
http://plnkr.co/edit/OSbiB5C0RDPsqXJV0yjy?p=preview
thanks @billyaraujo it works fine. The timeout did the trick. I thought it was a bug. 👍
Scroll to focus is not working on a newly added row when the new item is added to the bottom of the table. The plnkr link given above is working as expected when the new item is added at the top. i.e. $scope.gridOptions.data.unshift(newobj); But if I do this $scope.gridOptions.data.push(newobj); It is not working.
I'm using this to shift the focus to the newly added row
var rowIndex = $scope.gridOptions.data.length-1;
var colIndex = 1;
$scope.gridApi.cellNav.scrollToFocus($scope.gridOptions.data[rowIndex], $scope.gridOptions.columnDefs[colIndex]);
The newly added row is not visible. But if I scroll down to the bottom I'm able to see the new row.
Thanks for contributing! This repository has been transferred, and we're preparing the new 5.x release. We're closing older issues and pull requests as part of the reset. Please join us on Discord to follow the work or continue the conversation: https://discord.gg/Baz4w8ZWN