From e859aa6ebad1d9532532bd554144c801d451c83c Mon Sep 17 00:00:00 2001 From: zhixin Date: Sat, 12 Mar 2022 22:30:26 +0800 Subject: [PATCH 1/2] Added column-switch-all event of toggle all columns --- src/bootstrap-table.js | 1 + src/constants/index.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js index 7c92a118ab..78c9fb48c4 100644 --- a/src/bootstrap-table.js +++ b/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) { diff --git a/src/constants/index.js b/src/constants/index.js index f01b8ca4ec..4e5937b6f2 100644 --- a/src/constants/index.js +++ b/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', From 6c74fbea3ce295cd2bcb756483ad5e65201c6453 Mon Sep 17 00:00:00 2001 From: zhixin Date: Sat, 12 Mar 2022 22:48:02 +0800 Subject: [PATCH 2/2] Added onColumnSwitchAll docs --- index.d.ts | 1 + site/docs/api/events.md | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/index.d.ts b/index.d.ts index b39cf976e4..3272ce785a 100644 --- a/index.d.ts +++ b/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; diff --git a/site/docs/api/events.md b/site/docs/api/events.md index d167e473f2..2a5296274a 100644 --- a/site/docs/api/events.md +++ b/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`