浏览代码

Added serverSort option (#4726)

文翼 6 年之前
父节点
当前提交
849470729b
共有 3 个文件被更改,包括 16 次插入1 次删除
  1. 14 0
      site/docs/api/table-options.md
  2. 1 1
      src/bootstrap-table.js
  3. 1 0
      src/constants/index.js

+ 14 - 0
site/docs/api/table-options.md

@@ -271,6 +271,20 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Example:** [Remember Order](https://examples.bootstrap-table.com/#options/remember-order.html)
 
+## serverSort
+
+- **Attribute:** `data-server-sort`
+
+- **Type:** `Boolean`
+
+- **Detail:**
+
+  Set `false` to sort the data in the client side, only works when the `sidePagination` is `server`.
+
+- **Default:** `true`
+
+- **Example:** [Server Sort](https://examples.bootstrap-table.com/#options/server-sort.html)
+
 ## customSort
 
 - **Attribute:** `data-custom-sort`

+ 1 - 1
src/bootstrap-table.js

@@ -462,7 +462,7 @@ class BootstrapTable {
     // Assign the correct sortable arrow
     this.getCaret()
 
-    if (this.options.sidePagination === 'server') {
+    if (this.options.sidePagination === 'server' && this.options.serverSort) {
       this.options.pageNumber = 1
       this.initServer(this.options.silentSort)
       return

+ 1 - 0
src/constants/index.js

@@ -129,6 +129,7 @@ const DEFAULTS = {
   sortOrder: 'asc',
   sortStable: false,
   rememberOrder: false,
+  serverSort: true,
   customSort: undefined,
   columns: [
     []