Skip to content

Commit e616cf4

Browse files
committed
Merge pull request #2036 from mathiasdose/includeFiltersGridHeight
include filter height when calculating grid height
2 parents e4a045b + 124492e commit e616cf4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,23 @@ angular.module('ui.grid').directive('uiGrid',
210210
var footerHeight = grid.options.showFooter ? grid.options.footerRowHeight : 0;
211211
var scrollbarHeight = grid.options.enableScrollbars ? gridUtil.getScrollbarWidth() : 0;
212212

213-
var newHeight = headerHeight + contentHeight + footerHeight + scrollbarHeight;
213+
var maxNumberOfFilters = 0;
214+
// Calculates the maximum number of filters in the columns
215+
angular.forEach(grid.options.columnDefs, function(col) {
216+
if (col.hasOwnProperty('filter')) {
217+
if (maxNumberOfFilters < 1) {
218+
maxNumberOfFilters = 1;
219+
}
220+
}
221+
else if (col.hasOwnProperty('filters')) {
222+
if (maxNumberOfFilters < col.filters.length) {
223+
maxNumberOfFilters = col.filters.length;
224+
}
225+
}
226+
});
227+
var filterHeight = maxNumberOfFilters * headerHeight;
228+
229+
var newHeight = headerHeight + contentHeight + footerHeight + scrollbarHeight + filterHeight;
214230

215231
$elm.css('height', newHeight + 'px');
216232

0 commit comments

Comments
 (0)