Skip to content

Commit 4c32e3d

Browse files
committed
fix(Filtering): Redraw grid properly when scrolled
The grid was not setting the row offset properly when removing a filter when the grid was scrolled. This change adds a "rowsAltered" argument to Grid.refresh() which will then pass that argument to Grid.redrawInPlace() so the grid can be refreshed at the proper place. Fixes #2557
1 parent 09f478c commit 4c32e3d

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

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

+1-8
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,7 @@
242242
filterDeregisters.push($scope.$watch('col.filters[' + i + '].term', function(n, o) {
243243
if (n !== o) {
244244
uiGridCtrl.grid.api.core.raise.filterChanged();
245-
uiGridCtrl.grid.refresh()
246-
.then(function () {
247-
if (uiGridCtrl.prevScrollArgs && uiGridCtrl.prevScrollArgs.y && uiGridCtrl.prevScrollArgs.y.percentage) {
248-
var scrollEvent = new ScrollEvent(uiGridCtrl.grid,null,null,'uiGridHeaderCell.toggleMenu');
249-
scrollEvent.y.percentage = uiGridCtrl.prevScrollArgs.y.percentage;
250-
scrollEvent.fireScrollingEvent();
251-
}
252-
});
245+
uiGridCtrl.grid.refresh(true);
253246
}
254247
}));
255248
});

src/js/core/factories/Grid.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1809,11 +1809,9 @@ angular.module('ui.grid')
18091809
* @name refresh
18101810
* @methodOf ui.grid.class:Grid
18111811
* @description Refresh the rendered grid on screen.
1812-
*
1812+
* @params {boolean} [rowsAltered] Optional flag for refreshing when the number of rows has changed.
18131813
*/
1814-
Grid.prototype.refresh = function refresh() {
1815-
// gridUtil.logDebug('grid refresh');
1816-
1814+
Grid.prototype.refresh = function refresh(rowsAltered) {
18171815
var self = this;
18181816

18191817
var p1 = self.processRowsProcessors(self.rows).then(function (renderableRows) {
@@ -1825,11 +1823,11 @@ angular.module('ui.grid')
18251823
});
18261824

18271825
return $q.all([p1, p2]).then(function () {
1828-
self.redrawInPlace();
1826+
self.redrawInPlace(rowsAltered);
18291827

18301828
self.refreshCanvas(true);
18311829
});
1832-
};
1830+
};
18331831

18341832
/**
18351833
* @ngdoc function

0 commit comments

Comments
 (0)