Browse Source

Merge pull request #102 from wenzhixin/develop

Update branch
Dennis Hernández 9 years ago
parent
commit
41538029d7

+ 7 - 2
docs/_i18n/en/documentation/methods.md

@@ -120,7 +120,7 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <td>updateRow</td>
         <td>params</td>
         <td>
-        Update the specified row, the param contains following properties: <br>
+        Update the specified row(s), each param contains following properties: <br>
         index: the row index to be updated. <br>
         row: the new row data.
         </td>
@@ -129,7 +129,7 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <td>updateByUniqueId</td>
         <td>params</td>
         <td>
-        Update the specified row, the param contains following properties: <br>
+        Update the specified row(s), each param contains following properties: <br>
         id: a row id where the id should be the uniqueid field assigned to the table. <br>
         row: the new row data.
         </td>
@@ -275,6 +275,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <td>Get hidden columns.</td>
     </tr>
     <tr>
+        <td>getVisibleColumns</td>
+        <td>-</td>
+        <td>Get visible columns.</td>
+    </tr>
+    <tr>
         <td>scrollTo</td>
         <td>value</td>
         <td>Scroll to the number value position, the unit is 'px', set 'bottom' means scroll to the bottom.</td>

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

@@ -241,6 +241,11 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
         <td>Obtiene las columnas ocultas.</td>
     </tr>
     <tr>
+        <td>getVisibleColumns</td>
+        <td>-</td>
+        <td>Retorna las columnas visibles.</td>
+    </tr>
+    <tr>
         <td>scrollTo</td>
         <td>value</td>
         <td>Setea la posición del scroll, setear 'bottom' significa setear la posición del scroll al final de la tabla.</td>

+ 5 - 0
docs/_i18n/zh-cn/documentation/methods.md

@@ -259,6 +259,11 @@
         <td>获取隐藏的列。</td>
     </tr>
     <tr>
+        <td>getVisibleColumns</td>
+        <td>-</td>
+        <td>获取可见列。</td>
+    </tr>
+    <tr>
         <td>scrollTo</td>
         <td>value</td>
         <td>滚动到指定位置,单位为 px,设置 'bottom' 表示跳到最后。</td>

+ 31 - 14
src/bootstrap-table.js

@@ -2386,19 +2386,24 @@
     };
 
     BootstrapTable.prototype.updateByUniqueId = function (params) {
-        var rowId;
+        var that = this;
+        var allParams = $.isArray(params) ? params : [ params ];
 
-        if (!params.hasOwnProperty('id') || !params.hasOwnProperty('row')) {
-            return;
-        }
+        $.each(allParams, function(i, params) {
+            var rowId;
 
-        rowId = $.inArray(this.getRowByUniqueId(params.id), this.options.data);
+            if (!params.hasOwnProperty('id') || !params.hasOwnProperty('row')) {
+                return;
+            }
 
-        if (rowId === -1) {
-            return;
-        }
+            rowId = $.inArray(that.getRowByUniqueId(params.id), that.options.data);
+
+            if (rowId === -1) {
+                return;
+            }
+            $.extend(that.data[rowId], params.row);
+        });
 
-        $.extend(this.data[rowId], params.row);
         this.initSort();
         this.initBody(true);
     };
@@ -2415,10 +2420,16 @@
     };
 
     BootstrapTable.prototype.updateRow = function (params) {
-        if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
-            return;
-        }
-        $.extend(this.data[params.index], params.row);
+        var that = this;
+        var allParams = $.isArray(params) ? params : [ params ];
+
+        $.each(allParams, function(i, params) {
+            if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
+                return;
+            }
+            $.extend(that.data[params.index], params.row);
+        });
+
         this.initSort();
         this.initBody(true);
     };
@@ -2653,6 +2664,12 @@
         });
     };
 
+    BootstrapTable.prototype.getVisibleColumns = function () {
+        return $.grep(this.columns, function (column) {
+            return column.visible;
+        });
+    };
+
     BootstrapTable.prototype.toggleAllColumns = function (visible) {
         $.each(this.columns, function (i, column) {
             this.columns[i].visible = visible;
@@ -2846,7 +2863,7 @@
         'resetWidth',
         'destroy',
         'showLoading', 'hideLoading',
-        'showColumn', 'hideColumn', 'getHiddenColumns',
+        'showColumn', 'hideColumn', 'getHiddenColumns', 'getVisibleColumns',
         'showAllColumns', 'hideAllColumns',
         'filterBy',
         'scrollTo',