浏览代码

Merge pull request #6083 from wenzhixin/feature/6057

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

+ 1 - 0
index.d.ts

@@ -67,6 +67,7 @@ interface BootstrapTableEvents{
     'all.bs.table': string;
     'uncheck-all.bs.table': string;
     'column-switch.bs.table': string;
+    'column-switch-all.bs.table': string;
     'check.bs.table': string;
     'search.bs.table': string;
     'load-success.bs.table': string;

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

@@ -139,6 +139,18 @@ $('#table').on('event-name.bs.table', function (e, arg1, arg2, ...) {
   * `field`: the field name corresponding to the switch column.
   * `checked`: the checked state of the column.
 
+## onColumnSwitchAll
+
+- **jQuery Event:** `column-switch-all.bs.table`
+
+- **Parameter:** `checked`
+
+- **Detail:**
+
+  It fires when toogle all columns. The parameters contain:
+
+  * `checked`: the checked state of the column.
+
 ## onDblClickCell
 
 - **jQuery Event:** `dbl-click-cell.bs.table`

+ 1 - 0
src/bootstrap-table.js

@@ -810,6 +810,7 @@ class BootstrapTable {
 
       $toggleAll.off('click').on('click', ({ currentTarget }) => {
         this._toggleAllColumns($(currentTarget).prop('checked'))
+        this.trigger('column-switch-all', $(currentTarget).prop('checked'))
       })
 
       if (opts.showColumnsSearch) {

+ 4 - 0
src/constants/index.js

@@ -296,6 +296,9 @@ const DEFAULTS = {
   onColumnSwitch (field, checked) {
     return false
   },
+  onColumnSwitchAll (checked) {
+    return false
+  },
   onPageChange (number, size) {
     return false
   },
@@ -498,6 +501,7 @@ const EVENTS = {
   'load-success.bs.table': 'onLoadSuccess',
   'load-error.bs.table': 'onLoadError',
   'column-switch.bs.table': 'onColumnSwitch',
+  'column-switch-all.bs.table': 'onColumnSwitchAll',
   'page-change.bs.table': 'onPageChange',
   'search.bs.table': 'onSearch',
   'toggle.bs.table': 'onToggle',