浏览代码

Fix #7174 / Check if sticky header extension enabled in matchPositionX (#7398)

* Check if sticky header extension enabled in matchPositionX

* add enabled check to `renderStickyHeader` method

* Revert "add enabled check to `renderStickyHeader` method"

This reverts commit 13bbb9f25698f582757c6943fa5755af93fba24d.

* Revert "Check if sticky header extension enabled in matchPositionX"

This reverts commit 4afd85c7a12db77872667f4858e5038062f4aa99.

* add check under each `super.` method, remove first draft checks
Daniel Hirtzbruch 1 年之前
父节点
当前提交
5428c41f51
共有 1 个文件被更改,包括 14 次插入1 次删除
  1. 14 1
      src/extensions/sticky-header/bootstrap-table-sticky-header.js

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

@@ -16,7 +16,6 @@ Object.assign($.fn.bootstrapTable.defaults, {
 $.BootstrapTable = class extends $.BootstrapTable {
   initHeader (...args) {
     super.initHeader(...args)
-
     if (!this.options.stickyHeader) {
       return
     }
@@ -46,11 +45,18 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
   onColumnSearch ({ currentTarget, keyCode }) {
     super.onColumnSearch({ currentTarget, keyCode })
+    if (!this.options.stickyHeader) {
+      return
+    }
+
     this.renderStickyHeader()
   }
 
   resetView (...args) {
     super.resetView(...args)
+    if (!this.options.stickyHeader) {
+      return
+    }
 
     $('.bootstrap-table.fullscreen').off('scroll')
       .on('scroll', () => this.renderStickyHeader())
@@ -58,6 +64,9 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
   getCaret (...args) {
     super.getCaret(...args)
+    if (!this.options.stickyHeader) {
+      return
+    }
 
     if (this.$stickyHeader) {
       const $ths = this.$stickyHeader.find('th')
@@ -70,6 +79,10 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
   horizontalScroll () {
     super.horizontalScroll()
+    if (!this.options.stickyHeader) {
+      return
+    }
+
     this.$tableBody.on('scroll', () => this.matchPositionX())
   }