Browse Source

Added a 'getAllSelections' method to get checked rows across all pages and filters.

Tomer Shvueli 10 years ago
parent
commit
a4ddc85295
2 changed files with 15 additions and 2 deletions
  1. 6 1
      docs/_i18n/en/documentation/methods.md
  2. 9 1
      src/bootstrap-table.js

+ 6 - 1
docs/_i18n/en/documentation/methods.md

@@ -26,7 +26,12 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
     <tr>
         <td>getSelections</td>
         <td>none</td>
-        <td>Return all selected rows, when no record selected, am empty array will return.</td>
+        <td>Return selected rows, when no record selected, am empty array will return.</td>
+    </tr>
+    <tr>
+        <td>getAllSelections</td>
+        <td>none</td>
+        <td>Return selected rows in all pages, when no record selected, am empty array will return.</td>
     </tr>
     <tr>
         <td>getData</td>

+ 9 - 1
src/bootstrap-table.js

@@ -1836,6 +1836,14 @@
         });
     };
 
+    BootstrapTable.prototype.getAllSelections = function () {
+        var that = this;
+
+        return $.grep(this.options.data, function (row) {
+            return row[that.header.stateField];
+        });
+    };
+
     BootstrapTable.prototype.checkAll = function () {
         this.checkAll_(true);
     };
@@ -2014,7 +2022,7 @@
 
     var allowedMethods = [
         'getOptions',
-        'getSelections', 'getData',
+        'getSelections', 'getAllSelections', 'getData',
         'load', 'append', 'prepend', 'remove',
         'insertRow', 'updateRow',
         'showRow', 'hideRow', 'getRowsHidden',