Browse Source

Merge pull request #5590 from wenzhixin/fix/5532

Fixed stickyHeaderOffsetY option cannot work
Dustin Utecht 4 years ago
parent
commit
f847dee8b2
1 changed files with 13 additions and 1 deletions
  1. 13 1
      src/extensions/sticky-header/bootstrap-table-sticky-header.js

+ 13 - 1
src/extensions/sticky-header/bootstrap-table-sticky-header.js

@@ -56,6 +56,18 @@ $.BootstrapTable = class extends $.BootstrapTable {
       .on('scroll', () => this.renderStickyHeader())
   }
 
+  getCaret (...args) {
+    super.getCaret(...args)
+
+    if (this.$stickyHeader) {
+      const $ths = this.$stickyHeader.find('th')
+
+      this.$header.find('th').each((i, th) => {
+        $ths.eq(i).find('.sortable').attr('class', $(th).find('.sortable').attr('class'))
+      })
+    }
+  }
+
   horizontalScroll () {
     super.horizontalScroll()
     this.$tableBody.on('scroll', () => this.matchPositionX())
@@ -108,7 +120,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
         stickyHeaderOffsetLeft = 0
         stickyHeaderOffsetRight = 0
       }
-      this.$stickyContainer.css('top', `${this.options.stickyHeaderOffsetY}`)
+      this.$stickyContainer.css('top', `${this.options.stickyHeaderOffsetY}px`)
       this.$stickyContainer.css('left', `${stickyHeaderOffsetLeft}`)
       this.$stickyContainer.css('right', `${stickyHeaderOffsetRight}`)
       // create scrollable container for header