Skip to content

Commit

Permalink
fix(uiGridFooter): Watch for col change
Browse files Browse the repository at this point in the history
Update cell class on column change. This prevents the columns from losing
the right CSS settings when the columnDefs are swapped out.

Fixes #2686
  • Loading branch information
c0bra committed Apr 16, 2015
1 parent 8199eb5 commit 1f9100d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/js/core/directives/ui-grid-footer-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
//$elm.addClass($scope.col.getColClass(false));
$scope.grid = uiGridCtrl.grid;

$elm.addClass($scope.col.getColClass(false));
var initColClass = $scope.col.getColClass(false);
$elm.addClass(initColClass);

// apply any footerCellClass
var classAdded;
Expand All @@ -46,6 +47,19 @@
updateClass();
}

// Watch for column changes so we can alter the col cell class properly
$scope.$watch('col', function (n, o) {
if (n !== o) {
// See if the column's internal class has changed
var newColClass = $scope.col.getColClass(false);
if (newColClass !== initColClass) {
$elm.removeClass(initColClass);
$elm.addClass(newColClass);
initColClass = newColClass;
}
}
});

// Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs
var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateClass, [uiGridConstants.dataChange.COLUMN]);

Expand Down

0 comments on commit 1f9100d

Please sign in to comment.