|
218 | 218 | service.scrollTo(grid, $scope, rowEntity, colDef);
|
219 | 219 | },
|
220 | 220 |
|
| 221 | + /** |
| 222 | + * @ngdoc function |
| 223 | + * @name scrollToFocus |
| 224 | + * @methodOf ui.grid.cellNav.api:PublicApi |
| 225 | + * @description brings the specified row and column into view, and sets focus |
| 226 | + * to that cell |
| 227 | + * @param {Grid} grid the grid you'd like to act upon, usually available |
| 228 | + * from gridApi.grid |
| 229 | + * @param {object} $scope a scope we can broadcast events from |
| 230 | + * @param {object} rowEntity gridOptions.data[] array instance to make visible and set focus |
| 231 | + * @param {object} colDef to make visible and set focus |
| 232 | + */ |
| 233 | + scrollToFocus: function (grid, $scope, rowEntity, colDef) { |
| 234 | + service.scrollToFocus(grid, $scope, rowEntity, colDef); |
| 235 | + }, |
| 236 | + |
221 | 237 | /**
|
222 | 238 | * @ngdoc function
|
223 | 239 | * @name getFocusedCell
|
|
344 | 360 | this.scrollToInternal(grid, $scope, gridRow, gridCol);
|
345 | 361 | },
|
346 | 362 |
|
| 363 | + /** |
| 364 | + * @ngdoc method |
| 365 | + * @methodOf ui.grid.cellNav.service:uiGridCellNavService |
| 366 | + * @name scrollToFocus |
| 367 | + * @description Scroll the grid such that the specified |
| 368 | + * row and column is in view, and set focus to the cell in that row and column |
| 369 | + * @param {Grid} grid the grid you'd like to act upon, usually available |
| 370 | + * from gridApi.grid |
| 371 | + * @param {object} $scope a scope we can broadcast events from |
| 372 | + * @param {object} rowEntity gridOptions.data[] array instance to make visible and set focus to |
| 373 | + * @param {object} colDef to make visible and set focus to |
| 374 | + */ |
| 375 | + scrollToFocus: function (grid, $scope, rowEntity, colDef) { |
| 376 | + var gridRow = null, gridCol = null; |
| 377 | + |
| 378 | + if (rowEntity !== null) { |
| 379 | + gridRow = grid.getRow(rowEntity); |
| 380 | + } |
| 381 | + |
| 382 | + if (colDef !== null) { |
| 383 | + gridCol = grid.getColumn(colDef.name ? colDef.name : colDef.field); |
| 384 | + } |
| 385 | + this.scrollToInternal(grid, $scope, gridRow, gridCol); |
| 386 | + |
| 387 | + var rowCol = { row: gridRow, col: gridCol }; |
| 388 | + |
| 389 | + // Broadcast the navigation |
| 390 | + grid.cellNav.broadcastCellNav(rowCol); |
| 391 | + |
| 392 | + }, |
| 393 | + |
347 | 394 | /**
|
348 | 395 | * @ngdoc method
|
349 | 396 | * @methodOf ui.grid.cellNav.service:uiGridCellNavService
|
|
626 | 673 | compile: function () {
|
627 | 674 | return {
|
628 | 675 | pre: function ($scope, $elm, $attrs, uiGridCtrl) {
|
| 676 | + var _scope = $scope; |
629 | 677 |
|
630 | 678 | var grid = uiGridCtrl.grid;
|
631 | 679 | uiGridCellNavService.initializeGrid(grid);
|
|
637 | 685 | };
|
638 | 686 |
|
639 | 687 | // gridUtil.logDebug('uiGridEdit preLink');
|
640 |
| - uiGridCtrl.cellNav.broadcastCellNav = function (newRowCol) { |
641 |
| - $scope.$broadcast(uiGridCellNavConstants.CELL_NAV_EVENT, newRowCol); |
| 688 | + uiGridCtrl.cellNav.broadcastCellNav = grid.cellNav.broadcastCellNav = function (newRowCol) { |
| 689 | + _scope.$broadcast(uiGridCellNavConstants.CELL_NAV_EVENT, newRowCol); |
642 | 690 | uiGridCtrl.cellNav.broadcastFocus(newRowCol);
|
643 | 691 | };
|
644 | 692 |
|
|
0 commit comments