浏览代码

Fix fo #6402 introducing sortResetPage option

Marcel Overdijk 3 年之前
父节点
当前提交
0cab7eab3f
共有 3 个文件被更改,包括 19 次插入0 次删除
  1. 1 0
      index.d.ts
  2. 14 0
      site/docs/api/table-options.md
  3. 4 0
      src/bootstrap-table.js

+ 1 - 0
index.d.ts

@@ -162,6 +162,7 @@ export interface BootstrapTableOptions {
   pageSize?: number;
   footerField?: string;
   showFullscreen?: boolean;
+  sortPageReset?: boolean;
   sortStable?: boolean;
   searchAlign?: string;
   ajax?: (params: BootstrapAjaxParams) => any;

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

@@ -1657,6 +1657,20 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Example:** [Sort Reset](https://examples.bootstrap-table.com/#options/sort-reset.html)
 
+## sortResetPage
+
+- **Attribute:** `data-sort-reset-page`
+
+- **Type:** `Boolean`
+
+- **Detail:**
+
+  Set `true` to reset the page number when sorting
+
+- **Default:** `false`
+
+- **Example:** [Sort Reset Page](https://examples.bootstrap-table.com/#options/sort-reset-page.html)
+
 ## sortStable
 
 - **Attribute:** `data-sort-stable`

+ 4 - 0
src/bootstrap-table.js

@@ -557,6 +557,10 @@ class BootstrapTable {
       return
     }
 
+    if (this.options.pagination && this.options.sortResetPage) {
+      this.options.pageNumber = 1
+    }
+
     this.initSort()
     this.initBody()
   }