Browse Source

Added getRowsHidden method

Dennis Hernández 10 years ago
parent
commit
c646fe51e2

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

@@ -90,6 +90,12 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         isIdField: Boolean to indicates if index is the idField od the row or not.</td>
     </tr>
     <tr>
+        <td>getRowsHidden</td>
+        <td>boolean</td>
+        <td>Get all rows hidden and if you pass the show parameter true the rows will be shown again, otherwise, the method
+        only will return the rows hidden.</td>
+    </tr>
+    <tr>
         <td>mergeCells</td>
         <td>options</td>
         <td>

+ 6 - 0
docs/_i18n/es/documentation/methods.md

@@ -90,6 +90,12 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
         isIdField: Boolean que indica si el index es idField o la posición de la fila.</td>
     </tr>
     <tr>
+        <td>getRowsHidden</td>
+        <td>boolean</td>
+        <td>Obitnene todas las filas ocultas si se pasa el parámetro show en true las filas serán mostradas, sino, el método solo
+        devolvera las filas ocultas.</td>
+    </tr>
+    <tr>
         <td>mergeCells</td>
         <td>options</td>
         <td>

+ 20 - 12
src/bootstrap-table.js

@@ -1138,6 +1138,8 @@
             if (this.options.pageSize === this.options.formatAllRows()) {
                 this.options.pageSize = this.options.totalRows;
                 $allSelected = true;
+            } else if (this.options.pageSize === this.options.totalRows) {
+                $allSelected = true;
             }
 
             this.totalPages = ~~((this.options.totalRows - 1) / this.options.pageSize) + 1;
@@ -1850,13 +1852,8 @@
            return;
         }
 
-        if (isIdField) {
-            this.$selectItem.filter(sprintf('[value="%s"]', index))
-                .parents('tr')[visible ? 'show' : 'hide']();
-        } else {
-            this.$selectItem.filter(sprintf('[data-index="%s"]', index))
-                .parents('tr')[visible ? 'show' : 'hide']();
-        }
+        $(this.$body[0]).children().filter(sprintf( isIdField ? '[value="%s"]' : '[data-index="%s"]', index))
+            [visible ? 'show' : 'hide']();
      };
 
     // PUBLIC FUNCTION DEFINITION
@@ -1990,21 +1987,32 @@
     };
 
     BootstrapTable.prototype.showRow = function (params) {
-        if (!params.hasOwnProperty('index') || !params.hasOwnProperty('isIdField')) {
+        if (!params.hasOwnProperty('index')) {
             return;
         }
 
-        this.toggleRow(params.index, params.isIdField, true);
+        this.toggleRow(params.index, params.isIdField === undefined ? false : true, true);
     };
 
     BootstrapTable.prototype.hideRow = function (params) {
-        if (!params.hasOwnProperty('index') || !params.hasOwnProperty('isIdField')) {
+        if (!params.hasOwnProperty('index')) {
             return;
         }
 
-        this.toggleRow(params.index, params.isIdField, false);
+        this.toggleRow(params.index, params.isIdField === undefined ? false : true, false);
     };
 
+    BootstrapTable.prototype.getRowsHidden = function (show) {
+        var rows = $(this.$body[0]).children().filter(':hidden'),
+            i = 0;
+        if (show) {
+            for (; i < rows.length; i++) {
+                $(rows[i]).show();
+            }
+        }
+        return rows;
+    }
+
     BootstrapTable.prototype.mergeCells = function (options) {
         var row = options.index,
             col = $.inArray(options.field, this.header.fields),
@@ -2213,7 +2221,7 @@
         'getSelections', 'getData',
         'load', 'append', 'prepend', 'remove',
         'insertRow', 'updateRow',
-        'showRow', 'hideRow',
+        'showRow', 'hideRow', 'getRowsHidden',
         'mergeCells',
         'checkAll', 'uncheckAll',
         'check', 'uncheck',