Browse Source

Merge pull request #4979 from mattosaurus/filter-server-sort

Table Filter Control Server Side Sorting
文翼 5 years ago
parent
commit
1faa658078

+ 1 - 1
site/docs/extensions/filter-control.md

@@ -202,7 +202,7 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith
 
 - **Detail:**
 
-   Set this to order the options in a select control whether ascending or descending.
+   Set this to order the options in a select control whether ascending (`'asc'`), descending (`'desc'`) or in the order provided by the server (`'server'`).
 
 - **Default:** `'asc'`
 

+ 5 - 3
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -59,9 +59,11 @@ const UtilsFilterControl = {
     const $selectControl = $(selectControl.get(selectControl.length - 1))
     const $opts = $selectControl.find('option:gt(0)')
 
-    $opts.sort((a, b) => {
-      return Utils.sort(a.textContent, b.textContent, orderBy === 'desc' ? -1 : 1)
-    })
+    if (orderBy !== 'server') {
+      $opts.sort((a, b) => {
+        return Utils.sort(a.textContent, b.textContent, orderBy === 'desc' ? -1 : 1)
+      })
+    }
 
     $selectControl.find('option:gt(0)').remove()
     $selectControl.append($opts)