Skip to content

Commit

Permalink
fix(Filtering): Redraw grid properly when scrolled
Browse files Browse the repository at this point in the history
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
  • Loading branch information
c0bra committed Feb 23, 2015
1 parent 09f478c commit 4c32e3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
9 changes: 1 addition & 8 deletions src/js/core/directives/ui-grid-header-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,7 @@
filterDeregisters.push($scope.$watch('col.filters[' + i + '].term', function(n, o) {
if (n !== o) {
uiGridCtrl.grid.api.core.raise.filterChanged();
uiGridCtrl.grid.refresh()
.then(function () {
if (uiGridCtrl.prevScrollArgs && uiGridCtrl.prevScrollArgs.y && uiGridCtrl.prevScrollArgs.y.percentage) {
var scrollEvent = new ScrollEvent(uiGridCtrl.grid,null,null,'uiGridHeaderCell.toggleMenu');
scrollEvent.y.percentage = uiGridCtrl.prevScrollArgs.y.percentage;
scrollEvent.fireScrollingEvent();
}
});
uiGridCtrl.grid.refresh(true);
}
}));
});
Expand Down
10 changes: 4 additions & 6 deletions src/js/core/factories/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1809,11 +1809,9 @@ angular.module('ui.grid')
* @name refresh
* @methodOf ui.grid.class:Grid
* @description Refresh the rendered grid on screen.
*
* @params {boolean} [rowsAltered] Optional flag for refreshing when the number of rows has changed.
*/
Grid.prototype.refresh = function refresh() {
// gridUtil.logDebug('grid refresh');

Grid.prototype.refresh = function refresh(rowsAltered) {
var self = this;

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

return $q.all([p1, p2]).then(function () {
self.redrawInPlace();
self.redrawInPlace(rowsAltered);

self.refreshCanvas(true);
});
};
};

/**
* @ngdoc function
Expand Down

0 comments on commit 4c32e3d

Please sign in to comment.