Skip to content

Commit 1f9100d

Browse files
committed
fix(uiGridFooter): Watch for col change
Update cell class on column change. This prevents the columns from losing the right CSS settings when the columnDefs are swapped out. Fixes #2686
1 parent 8199eb5 commit 1f9100d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Diff for: src/js/core/directives/ui-grid-footer-cell.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
//$elm.addClass($scope.col.getColClass(false));
2323
$scope.grid = uiGridCtrl.grid;
2424

25-
$elm.addClass($scope.col.getColClass(false));
25+
var initColClass = $scope.col.getColClass(false);
26+
$elm.addClass(initColClass);
2627

2728
// apply any footerCellClass
2829
var classAdded;
@@ -46,6 +47,19 @@
4647
updateClass();
4748
}
4849

50+
// Watch for column changes so we can alter the col cell class properly
51+
$scope.$watch('col', function (n, o) {
52+
if (n !== o) {
53+
// See if the column's internal class has changed
54+
var newColClass = $scope.col.getColClass(false);
55+
if (newColClass !== initColClass) {
56+
$elm.removeClass(initColClass);
57+
$elm.addClass(newColClass);
58+
initColClass = newColClass;
59+
}
60+
}
61+
});
62+
4963
// Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs
5064
var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateClass, [uiGridConstants.dataChange.COLUMN]);
5165

0 commit comments

Comments
 (0)