Browse Source

Fix #607: empty header bug.

zhixin 10 years ago
parent
commit
bd749bef0e
2 changed files with 26 additions and 17 deletions
  1. 8 1
      src/bootstrap-table.css
  2. 18 16
      src/bootstrap-table.js

+ 8 - 1
src/bootstrap-table.css

@@ -23,13 +23,20 @@
 .fixed-table-footer,
 .fixed-table-footer,
 .fixed-table-header {
 .fixed-table-header {
     height: 37px; /*cellHeight*/
     height: 37px; /*cellHeight*/
-    border-bottom: 1px solid #dddddd;
     overflow: hidden;
     overflow: hidden;
     border-radius: 4px 4px 0 0;
     border-radius: 4px 4px 0 0;
     -webkit-border-radius: 4px 4px 0 0;
     -webkit-border-radius: 4px 4px 0 0;
     -moz-border-radius: 4px 4px 0 0;
     -moz-border-radius: 4px 4px 0 0;
 }
 }
 
 
+.fixed-table-header {
+    border-bottom: 1px solid #dddddd;
+}
+
+.fixed-table-footer {
+    border-top: 1px solid #dddddd;
+}
+
 .fixed-table-body {
 .fixed-table-body {
     overflow-x: auto;
     overflow-x: auto;
     overflow-y: auto;
     overflow-y: auto;

+ 18 - 16
src/bootstrap-table.js

@@ -689,15 +689,15 @@
     };
     };
 
 
     BootstrapTable.prototype.resetFooter = function () {
     BootstrapTable.prototype.resetFooter = function () {
-        var bt   = this,
-            data = bt.getData(),
+        var that = this,
+            data = that.getData(),
             html = [];
             html = [];
 
 
         if (!this.options.showFooter || this.options.cardView) { //do nothing
         if (!this.options.showFooter || this.options.cardView) { //do nothing
             return;
             return;
         }
         }
 
 
-        $.each(bt.options.columns, function (i, column) {
+        $.each(this.options.columns, function (i, column) {
             var falign = '', // footer align style
             var falign = '', // footer align style
                 style  = '',
                 style  = '',
                 class_ = sprintf(' class="%s"', column['class']);
                 class_ = sprintf(' class="%s"', column['class']);
@@ -720,34 +720,35 @@
             html.push('</td>');
             html.push('</td>');
         });
         });
 
 
-        bt.$footer.find('tr').html(html.join(''));
-        clearTimeout(bt.timeoutFooter_);
-        bt.timeoutFooter_ = setTimeout($.proxy(bt.fitFooter, bt), bt.$el.is(':hidden') ? 100: 0);
-        return;
+        this.$footer.find('tr').html(html.join(''));
+        clearTimeout(this.timeoutFooter_);
+        this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this),
+            this.$el.is(':hidden') ? 100: 0);
     };
     };
 
 
     BootstrapTable.prototype.fitFooter = function () {
     BootstrapTable.prototype.fitFooter = function () {
-        var bt = this,
+        var that = this,
             $fixedBody,
             $fixedBody,
             $footerTd,
             $footerTd,
             elWidth,
             elWidth,
             scrollWidth;
             scrollWidth;
-        clearTimeout(bt.timeoutFooter_);
-        if (bt.$el.is(':hidden')) {
-            bt.timeoutFooter_ = setTimeout($.proxy(bt.fitFooter, bt), 100);
+
+        clearTimeout(this.timeoutFooter_);
+        if (this.$el.is(':hidden')) {
+            this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), 100);
             return;
             return;
         }
         }
 
 
-        $fixedBody  = bt.$container.find('.fixed-table-body');
-        elWidth     = bt.$el.css('width');
+        $fixedBody  = this.$container.find('.fixed-table-body');
+        elWidth     = this.$el.css('width');
         scrollWidth = elWidth > $fixedBody.width() ? getScrollBarWidth() : 0;
         scrollWidth = elWidth > $fixedBody.width() ? getScrollBarWidth() : 0;
 
 
-        bt.$footer.css({
+        this.$footer.css({
             'margin-right': scrollWidth
             'margin-right': scrollWidth
         }).find('table').css('width', elWidth)
         }).find('table').css('width', elWidth)
-            .attr('class', bt.$el.attr('class'));
+            .attr('class', this.$el.attr('class'));
 
 
-        $footerTd = bt.$footer.find('td');
+        $footerTd = this.$footer.find('td');
 
 
         $fixedBody.find('tbody tr:first-child:not(.no-records-found) > td').each(function(i) {
         $fixedBody.find('tbody tr:first-child:not(.no-records-found) > td').each(function(i) {
             $footerTd.eq(i).outerWidth($(this).outerWidth());
             $footerTd.eq(i).outerWidth($(this).outerWidth());
@@ -1935,6 +1936,7 @@
             this.resetHeader();
             this.resetHeader();
             padding += cellHeight;
             padding += cellHeight;
         } else {
         } else {
+            this.$container.find('.fixed-table-header').hide();
             this.trigger('post-header');
             this.trigger('post-header');
         }
         }