Skip to content

Commit 509e007

Browse files
jcompagnerc0bra
authored andcommitted
fix(Grid): Redraw needs scrollTop when adding rows
Regression Fix for #2357 the scrollPercentage is not correct if there are added rows, because then the scrollPercentage should be recalculated.
1 parent 3b24342 commit 509e007

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/js/core/directives/ui-grid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
self.grid.modifyRows(newData)
109109
.then(function () {
110110
// if (self.viewport) {
111-
self.grid.redrawInPlace();
111+
self.grid.redrawInPlace(true);
112112
// }
113113

114114
$scope.$evalAsync(function() {

src/js/core/factories/Grid.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -2001,9 +2001,10 @@ angular.module('ui.grid')
20012001
* @name redrawCanvas
20022002
* @methodOf ui.grid.class:Grid
20032003
* @description Redraw the rows and columns based on our current scroll position
2004+
* @param {boolean} [rowsAdded] Optional to indicate rows are added and the scroll percentage must be recalculated
20042005
*
20052006
*/
2006-
Grid.prototype.redrawInPlace = function redrawInPlace() {
2007+
Grid.prototype.redrawInPlace = function redrawInPlace(rowsAdded) {
20072008
// gridUtil.logDebug('redrawInPlace');
20082009

20092010
var self = this;
@@ -2012,9 +2013,15 @@ angular.module('ui.grid')
20122013
var container = self.renderContainers[i];
20132014

20142015
// gridUtil.logDebug('redrawing container', i);
2015-
2016-
container.adjustRows(null, container.prevScrolltopPercentage, true);
2017-
container.adjustColumns(null, container.prevScrollleftPercentage);
2016+
2017+
if (rowsAdded) {
2018+
container.adjustRows(container.prevScrollTop, null);
2019+
container.adjustColumns(container.prevScrollTop, null);
2020+
}
2021+
else {
2022+
container.adjustRows(null, container.prevScrolltopPercentage);
2023+
container.adjustColumns(null, container.prevScrollleftPercentage);
2024+
}
20182025
}
20192026
};
20202027

0 commit comments

Comments
 (0)