浏览代码

Merge pull request #4656 from wenzhixin/fix/4314

Fixed sortStable cannot work bug
Dustin Utecht 6 年之前
父节点
当前提交
b0b179dc63
共有 2 个文件被更改,包括 5 次插入4 次删除
  1. 2 1
      src/bootstrap-table.js
  2. 3 3
      src/utils/index.js

+ 2 - 1
src/bootstrap-table.js

@@ -422,7 +422,8 @@ class BootstrapTable {
             return order * value
           }
 
-          return Utils.sort(aa, bb, order, this.options.sortStable)
+          return Utils.sort(aa, bb, order, this.options.sortStable,
+            a._position, b._position)
         })
       }
 

+ 3 - 3
src/utils/index.js

@@ -271,7 +271,7 @@ export default {
     return data
   },
 
-  sort (a, b, order, sortStable) {
+  sort (a, b, order, sortStable, aPosition, bPosition) {
     if (a === undefined || a === null) {
       a = ''
     }
@@ -280,8 +280,8 @@ export default {
     }
 
     if (sortStable && a === b) {
-      a = a._position
-      b = b._position
+      a = aPosition
+      b = bPosition
     }
 
     // If both values are numeric, do a numeric comparison