浏览代码

Added stickyHeaderOffsetLeft and stickyHeaderOffsetRight options for sticky-header extension

zhixin 6 年之前
父节点
当前提交
ffca2e0579
共有 2 个文件被更改,包括 26 次插入2 次删除
  1. 20 0
      site/docs/extensions/sticky-header.md
  2. 6 2
      src/extensions/sticky-header/bootstrap-table-sticky-header.js

+ 20 - 0
site/docs/extensions/sticky-header.md

@@ -39,3 +39,23 @@ This is an extension which provides a sticky header for the table when scrolling
    Set the Y offset from the top of the window to pin the sticky header. If there is a fixed navigation bar with a height of 60px, this value would be `60`.
    Set the Y offset from the top of the window to pin the sticky header. If there is a fixed navigation bar with a height of 60px, this value would be `60`.
 
 
 - **Default:** `0`
 - **Default:** `0`
+
+### stickyHeaderOffsetLeft
+
+- **type:** `Number | String`
+
+- **Detail:**
+
+   Set the left offset of the sticky header container.
+
+- **Default:** `0`
+
+### stickyHeaderOffsetRight
+
+- **type:** `Number | String`
+
+- **Detail:**
+
+   Set the right offset of the sticky header container.
+
+- **Default:** `0`

+ 6 - 2
src/extensions/sticky-header/bootstrap-table-sticky-header.js

@@ -8,7 +8,9 @@ const Utils = $.fn.bootstrapTable.utils
 
 
 $.extend($.fn.bootstrapTable.defaults, {
 $.extend($.fn.bootstrapTable.defaults, {
   stickyHeader: false,
   stickyHeader: false,
-  stickyHeaderOffsetY: 0
+  stickyHeaderOffsetY: 0,
+  stickyHeaderOffsetLeft: 0,
+  stickyHeaderOffsetRight: 0
 })
 })
 
 
 const hiddenClass = {
 const hiddenClass = {
@@ -56,7 +58,9 @@ $.BootstrapTable = class extends $.BootstrapTable {
       // match bootstrap table style
       // match bootstrap table style
       this.$stickyContainer.removeClass(hiddenClass).addClass('fix-sticky fixed-table-container')
       this.$stickyContainer.removeClass(hiddenClass).addClass('fix-sticky fixed-table-container')
       // stick it in position
       // stick it in position
-      this.$stickyContainer.css('top', `${this.options.stickyHeaderOffsetY}px`)
+      this.$stickyContainer.css('top', `${this.options.stickyHeaderOffsetY}`)
+      this.$stickyContainer.css('left', `${this.options.stickyHeaderOffsetLeft}`)
+      this.$stickyContainer.css('right', `${this.options.stickyHeaderOffsetRight}`)
       // create scrollable container for header
       // create scrollable container for header
       this.$stickyTable = $('<table/>')
       this.$stickyTable = $('<table/>')
       this.$stickyTable.addClass(this.options.classes)
       this.$stickyTable.addClass(this.options.classes)