浏览代码

Fixed check/uncheck all bug when using virtualScroll option

zhixin 5 年之前
父节点
当前提交
0448c11e5d
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/bootstrap-table.js

+ 12 - 0
src/bootstrap-table.js

@@ -1690,6 +1690,7 @@ class BootstrapTable {
         callback: () => {
           this.fitHeader()
           this.initBodyEvent()
+          this.updateSelected()
         }
       })
     }
@@ -1968,6 +1969,10 @@ class BootstrapTable {
   }
 
   updateSelected () {
+    if (!this.$selectItem.length) {
+      return
+    }
+
     const checkAll = this.$selectItem.filter(':enabled').length &&
       this.$selectItem.filter(':enabled').length ===
       this.$selectItem.filter(':enabled').filter(':checked').length
@@ -2779,6 +2784,13 @@ class BootstrapTable {
     this.updateRows()
     this.updateSelected()
 
+    if (this.options.virtualScroll) {
+      for (const row of this.data) {
+        row[this.header.stateField] = checked
+      }
+      this.initBody(true)
+    }
+
     const rowsAfter = this.getSelections()
 
     if (checked) {