浏览代码

Merge pull request #4273 from wenzhixin/fix/4097

Fix/4097
文翼 6 年之前
父节点
当前提交
aa0e7c7792
共有 2 个文件被更改,包括 13 次插入10 次删除
  1. 6 4
      site/docs/api/events.md
  2. 7 6
      src/bootstrap-table.js

+ 6 - 4
site/docs/api/events.md

@@ -134,25 +134,27 @@ $('#table').on('event-name.bs.table', function (e, arg1, arg2, ...) {
 
 - **jQuery Event:** `check-all.bs.table`
 
-- **Parameter:** `rows`
+- **Parameter:** `rowsAfter, rowsBefore`
 
 - **Detail:**
 
   Fires when user check all rows, the parameters contain:
 
-  * `rows`: array of records corresponding to newly checked rows.
+  * `rowsAfter`: array of records of the now checked rows.
+  * `rowsBefore`: array of records of the checked rows before.
 
 ## onUncheckAll
 
 - **jQuery Event:** `uncheck-all.bs.table`
 
-- **Parameter:** `rows`
+- **Parameter:** `rowsAfter, rowsBefore`
 
 - **Detail:**
 
   Fires when user uncheck all rows, the parameters contain:
 
-  * `rows`: array of records corresponding to previously checked rows.
+  * `rowsAfter`: array of records of the now checked rows.
+  * `rowsBefore`: array of records of the checked rows before.
 
 ## onCheckSome
 

+ 7 - 6
src/bootstrap-table.js

@@ -2373,17 +2373,18 @@ class BootstrapTable {
   }
 
   checkAll_ (checked) {
-    let rows
-    if (!checked) {
-      rows = this.getSelections()
-    }
+    const rowsBefore = this.getSelections()
     this.$selectAll.add(this.$selectAll_).prop('checked', checked)
     this.$selectItem.filter(':enabled').prop('checked', checked)
     this.updateRows()
+
+    const rowsAfter = this.getSelections()
     if (checked) {
-      rows = this.getSelections()
+      this.trigger('check-all', rowsAfter, rowsBefore)
+      return
     }
-    this.trigger(checked ? 'check-all' : 'uncheck-all', rows)
+
+    this.trigger('uncheck-all', rowsAfter, rowsBefore)
   }
 
   check (index) {