diff --git a/src/js/core/directives/ui-grid.js b/src/js/core/directives/ui-grid.js index 2a2d56ed91..4c65ec5254 100644 --- a/src/js/core/directives/ui-grid.js +++ b/src/js/core/directives/ui-grid.js @@ -108,7 +108,7 @@ self.grid.modifyRows(newData) .then(function () { // if (self.viewport) { - self.grid.redrawInPlace(); + self.grid.redrawInPlace(true); // } $scope.$evalAsync(function() { diff --git a/src/js/core/factories/Grid.js b/src/js/core/factories/Grid.js index b1f4418db6..a13bbbdfc7 100644 --- a/src/js/core/factories/Grid.js +++ b/src/js/core/factories/Grid.js @@ -2001,9 +2001,10 @@ angular.module('ui.grid') * @name redrawCanvas * @methodOf ui.grid.class:Grid * @description Redraw the rows and columns based on our current scroll position + * @param {boolean} [rowsAdded] Optional to indicate rows are added and the scroll percentage must be recalculated * */ - Grid.prototype.redrawInPlace = function redrawInPlace() { + Grid.prototype.redrawInPlace = function redrawInPlace(rowsAdded) { // gridUtil.logDebug('redrawInPlace'); var self = this; @@ -2012,9 +2013,15 @@ angular.module('ui.grid') var container = self.renderContainers[i]; // gridUtil.logDebug('redrawing container', i); - - container.adjustRows(null, container.prevScrolltopPercentage, true); - container.adjustColumns(null, container.prevScrollleftPercentage); + + if (rowsAdded) { + container.adjustRows(container.prevScrollTop, null); + container.adjustColumns(container.prevScrollTop, null); + } + else { + container.adjustRows(null, container.prevScrolltopPercentage); + container.adjustColumns(null, container.prevScrollleftPercentage); + } } };