浏览代码

Fix merge conflicts

djhvscf 5 年之前
父节点
当前提交
9aacb5dd93

+ 1 - 1
site/docs/api/column-options.md

@@ -16,7 +16,7 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
 
 - **Detail:**
 
-  The column field name.
+  The column field name. This field must be unique, or some unknown problems may occur.
 
 - **Default:** `undefined`
 

+ 10 - 0
site/docs/extensions/multiple-sort.md

@@ -38,6 +38,16 @@ toc: true
 
 - **Default:** `true`
 
+### multiSortStrictSort
+
+- **type:** `Boolean`
+
+- **Detail:**
+
+   Set true to enable strict sorting. This means that strings will be compared and ordered using toLowerCase.
+
+- **Default:** `false`
+
 ### sortPriority
 
 - **type:** `Object`

+ 7 - 7
src/bootstrap-table.js

@@ -127,11 +127,6 @@ class BootstrapTable {
       }
 
       this.$tableFooter = this.$container.find('.fixed-table-footer')
-    } else {
-      if (!this.$tableFooter.length) {
-        this.$el.append('<tfoot><tr></tr></tfoot>')
-        this.$tableFooter = this.$el.find('tfoot')
-      }
     }
   }
 
@@ -190,7 +185,7 @@ class BootstrapTable {
     // if options.data is setting, do not process tbody and tfoot data
     if (!this.options.data.length) {
       this.options.data = Utils.trToData(this.columns, this.$el.find('>tbody>tr'))
-      if (data.length) {
+      if (this.options.data.length) {
         this.fromHtml = true
       }
     }
@@ -771,7 +766,7 @@ class BootstrapTable {
         return
       }
 
-      const s = this.searchText && (this.options.escape
+      const s = this.searchText && (this.fromHtml
         ? Utils.escapeHTML(this.searchText) : this.searchText).toLowerCase()
       const f = Utils.isEmptyObject(this.filterColumns) ? null : this.filterColumns
 
@@ -1893,6 +1888,11 @@ class BootstrapTable {
       html.push('</th>')
     }
 
+    if (!this.options.height && !this.$tableFooter.length) {
+      this.$el.append('<tfoot><tr></tr></tfoot>')
+      this.$tableFooter = this.$el.find('tfoot')
+    }
+
     this.$tableFooter.find('tr').html(html.join(''))
 
     this.trigger('post-footer', this.$tableFooter)

+ 32 - 34
src/extensions/cookie/bootstrap-table-cookie.js

@@ -230,42 +230,40 @@ $.extend($.fn.bootstrapTable.utils, {
 
 $.BootstrapTable = class extends $.BootstrapTable {
   init () {
-    if (this.options.cookie) {
-      // FilterBy logic
-      const filterByCookie = JSON.parse(UtilsCookie.getCookie(this, this.options.cookieIdTable, UtilsCookie.cookieIds.filterBy))
-      this.filterColumns = filterByCookie ? filterByCookie : {}
-
-      // FilterControl logic
-      this.options.filterControls = []
-      this.options.filterControlValuesLoaded = false
-
-      this.options.cookiesEnabled = typeof this.options.cookiesEnabled === 'string' ?
-        this.options.cookiesEnabled.replace('[', '').replace(']', '')
-          .replace(/ /g, '').toLowerCase().split(',') :
-        this.options.cookiesEnabled
-
-      if (this.options.filterControl) {
-        const that = this
-        this.$el.on('column-search.bs.table', (e, field, text) => {
-          let isNewField = true
-
-          for (let i = 0; i < that.options.filterControls.length; i++) {
-            if (that.options.filterControls[i].field === field) {
-              that.options.filterControls[i].text = text
-              isNewField = false
-              break
-            }
-          }
-          if (isNewField) {
-            that.options.filterControls.push({
-              field,
-              text
-            })
+    // FilterBy logic
+    const filterByCookie = JSON.parse(UtilsCookie.getCookie(this, this.options.cookieIdTable, UtilsCookie.cookieIds.filterBy))
+    this.filterColumns = filterByCookie ? filterByCookie : {}
+
+    // FilterControl logic
+    this.options.filterControls = []
+    this.options.filterControlValuesLoaded = false
+
+    this.options.cookiesEnabled = typeof this.options.cookiesEnabled === 'string' ?
+      this.options.cookiesEnabled.replace('[', '').replace(']', '')
+        .replace(/'/g, '').replace(/ /g, '').toLowerCase().split(',') :
+      this.options.cookiesEnabled
+
+    if (this.options.filterControl) {
+      const that = this
+      this.$el.on('column-search.bs.table', (e, field, text) => {
+        let isNewField = true
+
+        for (let i = 0; i < that.options.filterControls.length; i++) {
+          if (that.options.filterControls[i].field === field) {
+            that.options.filterControls[i].text = text
+            isNewField = false
+            break
           }
+        }
+        if (isNewField) {
+          that.options.filterControls.push({
+            field,
+            text
+          })
+        }
 
-          UtilsCookie.setCookie(that, UtilsCookie.cookieIds.filterControl, JSON.stringify(that.options.filterControls))
-        }).on('created-controls.bs.table', UtilsCookie.initCookieFilters(that))
-      }
+        UtilsCookie.setCookie(that, UtilsCookie.cookieIds.filterControl, JSON.stringify(that.options.filterControls))
+      }).on('created-controls.bs.table', UtilsCookie.initCookieFilters(that))
     }
     super.init()
   }

+ 20 - 3
src/extensions/multiple-sort/bootstrap-table-multiple-sort.js

@@ -236,7 +236,7 @@ const bootstrap = {
                     </table>
                 </div>
               </div>
-              
+
               <button class="waves-effect waves-light button" data-close aria-label="Close modal" type="button">
                 <span aria-hidden="true">%s</span>
               </button>
@@ -432,6 +432,7 @@ $.fn.bootstrapTable.methods.push('multipleSort')
 $.extend($.fn.bootstrapTable.defaults, {
   showMultiSort: false,
   showMultiSortButton: true,
+  multiSortStrictSort: false,
   sortPriority: null,
   onMultipleSort () {
     return false
@@ -488,6 +489,7 @@ $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)
 
 const BootstrapTable = $.fn.bootstrapTable.Constructor
 const _initToolbar = BootstrapTable.prototype.initToolbar
+const _destroy = BootstrapTable.prototype.destroy
 
 BootstrapTable.prototype.initToolbar = function (...args) {
   this.showToolbar = this.showToolbar || this.options.showMultiSort
@@ -584,6 +586,14 @@ BootstrapTable.prototype.initToolbar = function (...args) {
   }
 }
 
+BootstrapTable.prototype.destroy = function (...args) {
+  _destroy.apply(this, Array.prototype.slice.apply(args))
+
+  if (this.options.showMultiSort) {
+    this.$sortModal.remove()
+  }
+}
+
 BootstrapTable.prototype.multipleSort = function () {
   const that = this
   if (!isSingleSort && that.options.sortPriority !== null && typeof that.options.sortPriority === 'object' && that.options.sidePagination !== 'server') {
@@ -608,15 +618,22 @@ BootstrapTable.prototype.onMultipleSort = function () {
       if (aa === undefined || aa === null) {
         aa = ''
       }
+
       if (bb === undefined || bb === null) {
         bb = ''
       }
+
       if ($.isNumeric(aa) && $.isNumeric(bb)) {
         aa = parseFloat(aa)
         bb = parseFloat(bb)
-      }
-      if (typeof aa !== 'string') {
+      } else {
         aa = aa.toString()
+        bb = bb.toString()
+
+        if (that.options.multiSortStrictSort) {
+          aa = aa.toLowerCase()
+          bb = bb.toLowerCase()
+        }
       }
 
       arr1.push(