Skip to content

Commit 34297a3

Browse files
committed
Merge pull request #3712 from PaulL1/fixes
Fix(footer): fix #3126 dynamic height when remove footer
2 parents 07e78d5 + 6b20ee7 commit 34297a3

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

misc/tutorial/105_footer.ngdoc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,17 @@ You can override the default grid footer template with gridOptions.footerTemplat
5252
onRegisterApi: function(gridApi) {
5353
$scope.gridApi = gridApi;
5454
}
55-
}
55+
};
56+
57+
$scope.toggleFooter = function() {
58+
$scope.gridOptions.showGridFooter = !$scope.gridOptions.showGridFooter;
59+
$scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
60+
};
61+
62+
$scope.toggleColumnFooter = function() {
63+
$scope.gridOptions.showColumnFooter = !$scope.gridOptions.showColumnFooter;
64+
$scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
65+
};
5666

5767
$http.get('/data/500_complex.json')
5868
.success(function(data) {
@@ -65,8 +75,8 @@ You can override the default grid footer template with gridOptions.footerTemplat
6575
</file>
6676
<file name="index.html">
6777
<div ng-controller="MainCtrl">
68-
<button id="footerButton" class="btn btn-success" ng-click="gridOptions.showGridFooter = !gridOptions.showGridFooter; $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);">Toggle Grid Footer</button>
69-
<button class="btn btn-success" ng-click="gridOptions.showColumnFooter = !gridOptions.showColumnFooter; $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);">Toggle Column Footer</button>
78+
<button id="footerButton" class="btn btn-success" ng-click="toggleFooter()">Toggle Grid Footer</button>
79+
<button class="btn btn-success" ng-click="toggleColumnFooter()">Toggle Column Footer</button>
7080
<div id="grid1" ui-grid="gridOptions" class="grid"></div>
7181
</div>
7282
</file>

src/js/core/factories/Grid.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ angular.module('ui.grid')
433433

434434
self.registerDataChangeCallback( self.columnRefreshCallback, [uiGridConstants.dataChange.COLUMN]);
435435
self.registerDataChangeCallback( self.processRowsCallback, [uiGridConstants.dataChange.EDIT]);
436+
self.registerDataChangeCallback( self.updateFooterHeightCallback, [uiGridConstants.dataChange.OPTIONS]);
436437

437438
self.registerStyleComputation({
438439
priority: 10,
@@ -645,6 +646,20 @@ angular.module('ui.grid')
645646
};
646647

647648

649+
/**
650+
* @ngdoc function
651+
* @name updateFooterHeightCallback
652+
* @methodOf ui.grid.class:Grid
653+
* @description recalculates the footer height,
654+
* registered as a dataChangeCallback on uiGridConstants.dataChange.OPTIONS
655+
* @param {string} name column name
656+
*/
657+
Grid.prototype.updateFooterHeightCallback = function updateFooterHeightCallback( grid ){
658+
grid.footerHeight = grid.calcFooterHeight();
659+
grid.columnFooterHeight = grid.calcColumnFooterHeight();
660+
};
661+
662+
648663
/**
649664
* @ngdoc function
650665
* @name getColumn

0 commit comments

Comments
 (0)