浏览代码

Fix the height bug when the children is hidden.

zhixin 10 年之前
父节点
当前提交
47dcd3d686
共有 1 个文件被更改,包括 12 次插入2 次删除
  1. 12 2
      src/bootstrap-table.js

+ 12 - 2
src/bootstrap-table.js

@@ -113,6 +113,16 @@
         return text;
         return text;
     };
     };
 
 
+    var getRealHeight = function ($el) {
+        var height = 0;
+        $el.children().each(function () {
+            if (height < $(this).outerHeight(true)) {
+                height = $(this).outerHeight(true);
+            }
+        });
+        return height;
+    };
+
     // BOOTSTRAP TABLE CLASS DEFINITION
     // BOOTSTRAP TABLE CLASS DEFINITION
     // ======================
     // ======================
 
 
@@ -1748,8 +1758,8 @@
             this.$selectItem.length === this.$selectItem.filter(':checked').length);
             this.$selectItem.length === this.$selectItem.filter(':checked').length);
 
 
         if (this.options.height) {
         if (this.options.height) {
-            var toolbarHeight = +this.$toolbar.children().outerHeight(true),
-                paginationHeight = +this.$pagination.children().outerHeight(true),
+            var toolbarHeight = getRealHeight(this.$toolbar),
+                paginationHeight = getRealHeight(this.$pagination),
                 height = this.options.height - toolbarHeight - paginationHeight;
                 height = this.options.height - toolbarHeight - paginationHeight;
 
 
             $tableContainer.css('height', height + 'px');
             $tableContainer.css('height', height + 'px');