ソースを参照

refs #1678: Fixed sortStable option cannot work bug

zhixin 7 年 前
コミット
99ab515935
1 ファイル変更4 行追加3 行削除
  1. 4 3
      src/bootstrap-table.js

+ 4 - 3
src/bootstrap-table.js

@@ -964,7 +964,9 @@
       if (index !== -1) {
         if (this.options.sortStable) {
           this.data.forEach((row, i) => {
-            row._position = i
+            if (!row.hasOwnProperty('_position')) {
+              row._position = i
+            }
           })
         }
 
@@ -978,7 +980,7 @@
 
           if (value !== undefined) {
             if (this.options.sortStable && value === 0) {
-              return a._position - b._position
+              return order * (a._position - b._position)
             }
             return order * value
           }
@@ -994,7 +996,6 @@
           if (this.options.sortStable && aa === bb) {
             aa = a._position
             bb = b._position
-            return a._position - b._position
           }
 
           // IF both values are numeric, do a numeric comparison