djhvscf 6 years ago
parent
commit
2af773b6a9
2 changed files with 23 additions and 8 deletions
  1. 6 3
      site/docs/api/methods.md
  2. 17 5
      src/bootstrap-table.js

+ 6 - 3
site/docs/api/methods.md

@@ -30,13 +30,16 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
 
 ## getData
 ## getData
 
 
-- **Parameter:** `useCurrentPage`
+ **Parameter:** `params`
 
 
 - **Detail:**
 - **Detail:**
 
 
-  Get the loaded data of table at the moment that this method is called. If you set the `useCurrentPage` to `true` the method will return the data in the current page.
+  Get the loaded data of table at the moment that this method is called
 
 
-- **Example:** [Get Data](https://examples.bootstrap-table.com/#methods/get-data.html)
+  * `useCurrentPage`: if set to true the method will return the data only in the current page.
+  * `includeHiddenRows`: if set to true the method will include the hidden rows.
+
+- **Example:** [Get Data](https://examples.bootstrap-table.com/#methods/getData.html)
 
 
 ## getSelections
 ## getSelections
 
 

+ 17 - 5
src/bootstrap-table.js

@@ -821,7 +821,7 @@ class BootstrapTable {
     let $pre
     let $pre
     let $next
     let $next
     let $number
     let $number
-    const data = this.getData()
+    const data = this.getData({includeHiddenRows: false})
     let pageList = o.pageList
     let pageList = o.pageList
 
 
     if (o.sidePagination !== 'server') {
     if (o.sidePagination !== 'server') {
@@ -1903,14 +1903,21 @@ class BootstrapTable {
     this.init()
     this.init()
   }
   }
 
 
-  getData (useCurrentPage) {
+  getData (params) {
     let data = this.options.data
     let data = this.options.data
     if (this.searchText || this.options.sortName || !Utils.isEmptyObject(this.filterColumns) || !Utils.isEmptyObject(this.filterColumnsPartial)) {
     if (this.searchText || this.options.sortName || !Utils.isEmptyObject(this.filterColumns) || !Utils.isEmptyObject(this.filterColumnsPartial)) {
       data = this.data
       data = this.data
     }
     }
 
 
-    if (useCurrentPage) {
-      return data.slice(this.pageFrom - 1, this.pageTo)
+    if (params && params.useCurrentPage) {
+      data = data.slice(this.pageFrom - 1, this.pageTo)
+    }
+
+    if (params && !params.includeHiddenRows) {
+      const hiddenRows = this.getHiddenRows()
+      data = data.filter(function (row) {
+        return Utils.findIndex(hiddenRows, row) === -1
+      })
     }
     }
 
 
     return data
     return data
@@ -2178,7 +2185,12 @@ class BootstrapTable {
     } else if (visible && index > -1) {
     } else if (visible && index > -1) {
       this.hiddenRows.splice(index, 1)
       this.hiddenRows.splice(index, 1)
     }
     }
-    this.initBody(true)
+    if (visible) {
+      this.updatePagination()
+    } else {
+      this.initBody(true)
+      this.initPagination()
+    }
   }
   }
 
 
   getHiddenRows (show) {
   getHiddenRows (show) {