浏览代码

Show/Hide row by idField

Dennis Hernández 10 年之前
父节点
当前提交
7cf356ae1a
共有 3 个文件被更改,包括 36 次插入15 次删除
  1. 8 4
      docs/_i18n/en/documentation/methods.md
  2. 8 4
      docs/_i18n/es/documentation/methods.md
  3. 20 7
      src/bootstrap-table.js

+ 8 - 4
docs/_i18n/en/documentation/methods.md

@@ -77,13 +77,17 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
     </tr>
 	<tr>
         <td>showRow</td>
-        <td>index</td>
-        <td>Show the specified row.</td>
+        <td>params</td>
+        <td>Show the specified row. the param contains following properties:
+        index: the row idenx or the idField.
+        isIdField: Boolean to indicates if index is the idField od the row or not.</td>
     </tr>
     <tr>
         <td>hideRow</td>
-        <td>index</td>
-        <td>Hide the specified row.</td>
+        <td>params</td>
+        <td>Hide the specified row. the param contains following properties:
+        index: the row idenx or the idField.
+        isIdField: Boolean to indicates if index is the idField od the row or not.</td>
     </tr>
     <tr>
         <td>mergeCells</td>

+ 8 - 4
docs/_i18n/es/documentation/methods.md

@@ -77,13 +77,17 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
     </tr>
 	<tr>
         <td>showRow</td>
-        <td>index</td>
-        <td>Muesta la fila especificada.</td>
+        <td>params</td>
+        <td>Muesta la fila especificada. El parámetro contiene los siguiente propiedades: <br>
+        index: el indice o idField de la fila.
+        isIdField: Boolean que indica si el index es idField o la posición de la fila.</td>
     </tr>
     <tr>
         <td>hideRow</td>
-        <td>index</td>
-        <td>Oculta la fila especificada.</td>
+        <td>params</td>
+        <td>Oculta la fila especificada. El parámetro contiene los siguiente propiedades: <br>
+        index: el indice o idField de la fila.
+        isIdField: Boolean que indica si el index es idField o la posición de la fila.</td>
     </tr>
     <tr>
         <td>mergeCells</td>

+ 20 - 7
src/bootstrap-table.js

@@ -1717,13 +1717,18 @@
         }
     };
 
-    BootstrapTable.prototype.toggleRow = function (index, visible) {
+    BootstrapTable.prototype.toggleRow = function (index, isIdField, visible) {
         if (index === -1) {
            return;
         }
 
-        this.$selectItem.filter(sprintf('[data-index="%s"]', index))
-            .parents('tr')[visible ? 'show' : 'hide']();
+        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']();
+        }
      };
 
     // PUBLIC FUNCTION DEFINITION
@@ -1854,12 +1859,20 @@
         this.initBody(true);
     };
 
-    BootstrapTable.prototype.showRow = function (index) {
-        this.toggleRow(index, true);
+    BootstrapTable.prototype.showRow = function (params) {
+        if (!params.hasOwnProperty('index') || !params.hasOwnProperty('isIdField')) {
+            return;
+        }
+
+        this.toggleRow(params.index, params.isIdField, true);
     };
 
-    BootstrapTable.prototype.hideRow = function (index) {
-        this.toggleRow(index, false);
+    BootstrapTable.prototype.hideRow = function (params) {
+        if (!params.hasOwnProperty('index') || !params.hasOwnProperty('isIdField')) {
+            return;
+        }
+
+        this.toggleRow(params.index, params.isIdField, false);
     };
 
     BootstrapTable.prototype.mergeCells = function (options) {