浏览代码

Added a new event, which is triggered if the pagination was toggled

Dustin Utecht 4 年之前
父节点
当前提交
a53671b36d
共有 3 个文件被更改,包括 18 次插入1 次删除
  1. 12 0
      site/docs/api/events.md
  2. 1 0
      src/bootstrap-table.js
  3. 5 1
      src/constants/index.js

+ 12 - 0
site/docs/api/events.md

@@ -348,6 +348,18 @@ $('#table').on('event-name.bs.table', function (e, arg1, arg2, ...) {
 
   * `cardView`: the cardView state of the table.
 
+## onTogglePagination
+
+- **jQuery Event:** `toggle-pagination.bs.table`
+
+- **Parameter:** `state`
+
+- **Detail:**
+
+  Fires when the pagination was toggled:
+
+  * `state`: the new pagination state (`true`-> Pagination is enabled, `false` -> Pagination is disabled )
+
 ## onUncheck
 
 - **jQuery Event:** `uncheck.bs.table`

+ 1 - 0
src/bootstrap-table.js

@@ -3080,6 +3080,7 @@ class BootstrapTable {
     this.$toolbar.find('button[name="paginationSwitch"]')
       .html(`${Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, icon) } ${ text}`)
     this.updatePagination()
+    this.trigger('toggle-pagination', this.options.pagination)
   }
 
   toggleFullscreen () {

+ 5 - 1
src/constants/index.js

@@ -394,6 +394,9 @@ const DEFAULTS = {
   },
   onScrollBody () {
     return false
+  },
+  onTogglePagination (newState) {
+    return false
   }
 }
 
@@ -564,7 +567,8 @@ const EVENTS = {
   'refresh-options.bs.table': 'onRefreshOptions',
   'reset-view.bs.table': 'onResetView',
   'refresh.bs.table': 'onRefresh',
-  'scroll-body.bs.table': 'onScrollBody'
+  'scroll-body.bs.table': 'onScrollBody',
+  'toggle-pagination.bs.table': 'onTogglePagination'
 }
 
 Object.assign(DEFAULTS, EN)