浏览代码

Merge branch 'develop' into dependabot/npm_and_yarn/stylelint-config-standard-22.0.0

文翼 4 年之前
父节点
当前提交
7d33473b95

+ 2 - 2
site/docs/extensions/custom-view.md

@@ -76,11 +76,11 @@ This extension adds the ability to create a custom view to display the data.
 
 ## Events
 
-### onCustomViewPostBody(custom-view-post-body.bs.table)
+### onCustomViewPreBody(custom-view-pre-body.bs.table)
 
 * Fires before the custom view was rendered.
 
-### onCustomViewPreBody(custom-view-pre-body.bs.table)
+### onCustomViewPostBody(custom-view-post-body.bs.table)
 
 * Fires after the custom view was rendered.
 

+ 7 - 10
src/bootstrap-table.js

@@ -391,16 +391,6 @@ class BootstrapTable {
       }
     })
 
-    this.$header.children().children().off('keypress').on('keypress', e => {
-      if (this.options.sortable && $(e.currentTarget).data().sortable) {
-        const code = e.keyCode || e.which
-
-        if (code === 13) { // Enter keycode
-          this.onSort(e)
-        }
-      }
-    })
-
     const resizeEvent = Utils.getEventName('resize.bootstrap-table', this.$el.attr('id'))
 
     $(window).off(resizeEvent)
@@ -1951,6 +1941,12 @@ class BootstrapTable {
         }
       },
       error: jqXHR => {
+        // abort ajax by multiple request
+        if (jqXHR && jqXHR.status === 0 && this._xhrAbort) {
+          this._xhrAbort = false
+          return
+        }
+
         let data = []
 
         if (this.options.sidePagination === 'server') {
@@ -1968,6 +1964,7 @@ class BootstrapTable {
       Utils.calculateObjectValue(this, this.options.ajax, [request], null)
     } else {
       if (this._xhr && this._xhr.readyState !== 4) {
+        this._xhrAbort = true
         this._xhr.abort()
       }
       this._xhr = $.ajax(request)

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

@@ -107,8 +107,12 @@ $.BootstrapTable = class extends $.BootstrapTable {
     // show sticky when top anchor touches header, and when bottom anchor not exceeded
     if (top > start && top <= end) {
       // ensure clone and source column widths are the same
-      this.$stickyHeader.find('tr:eq(0)').find('th').each((index, el) => {
-        $(el).css('min-width', this.$header.find('tr:eq(0)').find('th').eq(index).css('width'))
+      this.$stickyHeader.find('tr').each((indexRows, rows) => {
+        const columns = $(rows).find('th')
+
+        columns.each((indexColumns, celd) => {
+          $(celd).css('min-width', this.$header.find(`tr:eq(${indexRows})`).find(`th:eq(${indexColumns})`).css('width'))
+        })
       })
       // match bootstrap table style
       this.$stickyContainer.show().addClass('fix-sticky fixed-table-container')