|
290 | 290 | /** |
291 | 291 | * @ngdoc method |
292 | 292 | * @methodOf ui.grid.cellNav.service:uiGridCellNavService |
293 | | - * @name scrollVerticallyTo |
294 | | - * @description Scroll the grid vertically such that the specified |
295 | | - * row is in view |
| 293 | + * @name scrollTo |
| 294 | + * @description Scroll the grid such that the specified |
| 295 | + * row and column is in view |
296 | 296 | * @param {Grid} grid the grid you'd like to act upon, usually available |
297 | 297 | * from gridApi.grid |
298 | 298 | * @param {object} $scope a scope we can broadcast events from |
299 | 299 | * @param {object} rowEntity gridOptions.data[] array instance to make visible |
300 | 300 | * @param {object} colDef to make visible |
301 | 301 | */ |
302 | 302 | scrollTo: function (grid, $scope, rowEntity, colDef) { |
303 | | - var args = {}; |
| 303 | + var gridRow = null, gridCol = null; |
304 | 304 |
|
305 | 305 | if ( rowEntity !== null ){ |
306 | | - var row = grid.getRow(rowEntity); |
307 | | - if ( row ) { |
308 | | - args.y = { percentage: row.index / grid.renderContainers.body.visibleRowCache.length }; |
309 | | - } |
| 306 | + gridRow = grid.getRow(rowEntity); |
310 | 307 | } |
311 | 308 |
|
312 | 309 | if ( colDef !== null ){ |
313 | | - var col = grid.getColumn(colDef.name ? colDef.name : colDef.field); |
314 | | - if ( col ) { |
315 | | - args.x = { percentage: this.getLeftWidth(grid, col.index) / this.getLeftWidth(grid, grid.renderContainers.body.visibleColumnCache.length - 1) }; |
316 | | - } |
| 310 | + gridCol = grid.getColumn(colDef.name ? colDef.name : colDef.field); |
| 311 | + } |
| 312 | + this.scrollToInternal(grid, $scope, gridRow, gridCol); |
| 313 | + }, |
| 314 | + |
| 315 | + |
| 316 | + /** |
| 317 | + * @ngdoc method |
| 318 | + * @methodOf ui.grid.cellNav.service:uiGridCellNavService |
| 319 | + * @name scrollToInternal |
| 320 | + * @description Like scrollTo, but takes gridRow and gridCol |
| 321 | + * @param {Grid} grid the grid you'd like to act upon, usually available |
| 322 | + * from gridApi.grid |
| 323 | + * @param {object} $scope a scope we can broadcast events from |
| 324 | + * @param {GridRow} gridRow row to make visible |
| 325 | + * @param {GridCol} gridCol column to make visible |
| 326 | + */ |
| 327 | + scrollToInternal: function( grid, $scope, gridRow, gridCol ){ |
| 328 | + var args = {}; |
| 329 | + |
| 330 | + if ( gridRow !== null ){ |
| 331 | + args.y = { percentage: gridRow.index / grid.renderContainers.body.visibleRowCache.length }; |
| 332 | + } |
| 333 | + |
| 334 | + if ( gridCol !== null ){ |
| 335 | + args.x = { percentage: this.getLeftWidth(grid, gridCol.index) / this.getLeftWidth(grid, grid.renderContainers.body.visibleColumnCache.length - 1) }; |
317 | 336 | } |
318 | 337 |
|
319 | 338 | if ( args.y || args.x ){ |
|
477 | 496 | var div = $elm.find('div'); |
478 | 497 | div[0].focus(); |
479 | 498 | div.attr("tabindex", 0); |
| 499 | + $scope.grid.queueRefresh(); |
480 | 500 | } |
481 | 501 |
|
482 | 502 | } |
|
0 commit comments