浏览代码

return rows before and after (un)check all

Dustin Utecht 6 年之前
父节点
当前提交
6ce3615788
共有 1 个文件被更改,包括 7 次插入6 次删除
  1. 7 6
      src/bootstrap-table.js

+ 7 - 6
src/bootstrap-table.js

@@ -2377,17 +2377,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) {