浏览代码

Fix/5666 (#5667)

* Added an parameter to decide if the check by function should be applied
to the whole dataset or just to the visible data

* Added documentation
Dustin Utecht 4 年之前
父节点
当前提交
cecf35170c
共有 2 个文件被更改,包括 4 次插入1 次删除
  1. 2 0
      site/docs/api/methods.md
  2. 2 1
      src/bootstrap-table.js

+ 2 - 0
site/docs/api/methods.md

@@ -48,6 +48,7 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   * `field`: name of the field used to find records.
   * `values`: array of values for rows to check.
+  * `onlyCurrentPage (default false)`: If `true` only the visible dataset will be checked. If pagination is used the other pages will be ignored.
 
 - **Example:** [Check/Uncheck By](https://examples.bootstrap-table.com/#methods/check-uncheck-by.html)
 
@@ -578,6 +579,7 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   * `field`: name of the field used to find records.
   * `values`: array of values for rows to uncheck.
+  * `onlyCurrentPage (default false)`: If `true` only the visible dataset will be unchecked. If pagination is used the other pages will be ignored.
 
 - **Example:** [Check/Uncheck By](https://examples.bootstrap-table.com/#methods/check-uncheck-by.html)
 

+ 2 - 1
src/bootstrap-table.js

@@ -2906,10 +2906,11 @@ class BootstrapTable {
       if (obj.values.includes(row[obj.field])) {
         let $el = this.$selectItem.filter(':enabled')
           .filter(Utils.sprintf('[data-index="%s"]', i))
+        const onlyCurrentPage = obj.hasOwnProperty('onlyCurrentPage') ? obj.onlyCurrentPage : false
 
         $el = checked ? $el.not(':checked') : $el.filter(':checked')
 
-        if (!$el.length) {
+        if (!$el.length && onlyCurrentPage) {
           return
         }