Browse Source

6403: reset optimization

Marcel Overdijk 3 years ago
parent
commit
2a72927b09
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/bootstrap-table.js

+ 8 - 1
src/bootstrap-table.js

@@ -527,7 +527,14 @@ class BootstrapTable {
       } else if (currentSortOrder === 'asc') {
         this.options.sortOrder = 'desc'
       } else if (this.options.sortOrder === 'desc') {
-        this.options.sortOrder = this.options.sortReset ? undefined : 'asc'
+        if (this.options.sortReset) {
+          const initialSortOrder = this.columns[this.fieldsColumnsIndex[$this.data('field')]].sortOrder ||
+            this.columns[this.fieldsColumnsIndex[$this.data('field')]].order
+          this.options.sortOrder = initialSortOrder === 'desc' ? 'asc' : undefined
+        } else {
+          this.options.sortOrder = 'asc'
+        }
+        // this.options.sortOrder = this.options.sortReset ? undefined : 'asc'
       }
 
       if (this.options.sortOrder === undefined) {