浏览代码

Merge pull request #4807 from wenzhixin/bugfix/fix-bug-4736

Fixing strings comparation
文翼 5 年之前
父节点
当前提交
c63660fedb
共有 2 个文件被更改,包括 20 次插入2 次删除
  1. 10 0
      site/docs/extensions/multiple-sort.md
  2. 10 2
      src/extensions/multiple-sort/bootstrap-table-multiple-sort.js

+ 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`

+ 10 - 2
src/extensions/multiple-sort/bootstrap-table-multiple-sort.js

@@ -432,6 +432,7 @@ $.fn.bootstrapTable.methods.push('multipleSort')
 $.extend($.fn.bootstrapTable.defaults, {
   showMultiSort: false,
   showMultiSortButton: true,
+  multiSortStrictSort: false,
   sortPriority: null,
   onMultipleSort () {
     return false
@@ -617,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(