Browse Source

Merge pull request #885 from djhvscf/master

Some new features
文翼 10 years ago
parent
commit
90cd1214f8

+ 18 - 0
docs/_i18n/en/documentation/events.md

@@ -94,6 +94,24 @@
         </td>
     </tr>
     <tr>
+        <td>onCheckSome</td>
+        <td>check-some.bs.table</td>
+        <td>rows</td>
+        <td>
+        Fires when user check some rows, the parameters contains: <br>
+        rows: array of records corresponding to previously checked rows.
+        </td>
+    </tr>
+    <tr>
+        <td>onUncheckSome</td>
+        <td>uncheck-some.bs.table</td>
+        <td>rows</td>
+        <td>
+        Fires when user uncheck some rows, the parameters contains: <br>
+        rows: array of records corresponding to previously checked rows.
+        </td>
+    </tr>
+    <tr>
         <td>onLoadSuccess</td>
         <td>load-success.bs.table</td>
         <td>data</td>

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

@@ -129,6 +129,16 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         </td>
     </tr>
     <tr>
+        <td>updateCell</td>
+        <td>params</td>
+        <td>
+        Update one cell, the params contains following properties: <br>
+        rowIndex: the row index. <br>
+        fieldName: the field name.<br>
+        fieldValue: the new field value. <br>
+        </td>
+    </tr>
+    <tr>
         <td>refresh</td>
         <td>params</td>
         <td>Refresh the remote server data, you can set <code>{silent: true}</code> to refresh the data silently, and set <code>{url: newUrl}</code> to change the url. To supply query params specific to this request, set <code>{query: {foo: 'bar'}}</code></td>

+ 27 - 7
docs/_i18n/es/documentation/events.md

@@ -71,20 +71,40 @@
         <td>row</td>
         <td>
         Se ejecuta cuando el usuario des-chequea una fila, los parámetros contienen: <br>
-        row: el registro que corresponde a la fila des-chequeada.
+        row: el registro que corresponde a la fila deschequeada.
         </td>
     </tr>
     <tr>
         <td>onCheckAll</td>
         <td>check-all.bs.table</td>
-        <td>none</td>
-        <td>Fires when user check all rows.</td>
+        <td>rows</td>
+        <td>Se ejecuta cuando el usuario chequea todas las filas, los parámetros contienen: <br>
+        rows: arreglo de las filas chequeadas.</td>
     </tr>
     <tr>
         <td>onUncheckAll</td>
         <td>uncheck-all.bs.table</td>
-        <td>none</td>
-        <td>Se ejecuta cuando el usuario des-chequea todas las filas.</td>
+        <td>rows</td>
+        <td>Se ejecuta cuando el usuario des-chequea todas las filas, los parámetros contienen: <br>
+        rows: arreglo de las filas deschequeadas.</td>
+    </tr>
+    <tr>
+        <td>onCheckSome</td>
+        <td>check-some.bs.table</td>
+        <td>rows</td>
+        <td>
+        Se ejecuta cuando el usuario chequea algunas filas, los parámetros contienen: <br>
+        rows: arreglo de las filas chequeadas.
+        </td>
+    </tr>
+    <tr>
+        <td>onUncheckSome</td>
+        <td>uncheck-some.bs.table</td>
+        <td>rows</td>
+        <td>
+        Se ejecuta cuando el usuario deschequea algunas filas, los parámetros contienen: <br>
+        rows: arreglo de las filas deschequeadas.
+        </td>
     </tr>
     <tr>
         <td>onLoadSuccess</td>
@@ -144,13 +164,13 @@
         <td>onExpandRow</td>
         <td>expand-row.bs.table</td>
         <td>index, row, $detail</td>
-        <td>Fires when click the detail icon to expand the detail view.</td>
+        <td>Se ejecuta cuando se da click al icono de detalle para expandir la vista detalle.</td>
     </tr>
     <tr>
        <td>onCollapseRow</td>
        <td>collapse-row.bs.table</td>
        <td>index, row</td>
-       <td>Fires when click the detail icon to collapse the detail view.</td>
+       <td>Se ejecuta cuando se da click al icono de detalle para colapsar la vista detalle.</td>
     </tr>
     </tbody>
 </table>

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

@@ -125,6 +125,16 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
         </td>
     </tr>
     <tr>
+        <td>updateCell</td>
+        <td>params</td>
+        <td>
+        Actualiza una celda, los parámetros contienen: <br>
+        rowIndex: índice de la fila. <br>
+        fieldName: el nombre del campo.<br>
+        fieldValue: el nuevo valor de la celda. <br>
+        </td>
+    </tr>
+    <tr>
         <td>refresh</td>
         <td>params</td>
         <td>Refresca los datos remotos del servidor, se puede setear <code>{silent: true}</code> para refrescar los datos silenciosamente, y setear <code>{url: newUrl}</code> para cambiar el URL. Para suministrar query params especificos para este request, setear <code>{query: {foo: 'bar'}}</code></td>

+ 2 - 2
docs/_i18n/es/documentation/table-options.md

@@ -319,14 +319,14 @@ Las opciones de la tabla están definidas en `jQuery.fn.bootstrapTable.defaults`
         <td>data-detail-view</td>
         <td>Boolean</td>
         <td>false</td>
-        <td>True to show detail view table.</td>
+        <td>True para mostrar la vista detalle en la tabla.</td>
     </tr>
     <tr>
         <td>detailFormatter</td>
         <td>data-detail-formatter</td>
         <td>Function</td>
         <td>function(index, row) {<br>return '';<br>}</td>
-        <td>Format your detail view when <code>detailView</code> is set to <code>true</code>.</td>
+        <td>Formatee su vista detalle cuando <code>detailView</code> está seteada en <code>true</code>.</td>
     </tr>
     <tr>
         <td>searchAlign</td>

+ 18 - 0
docs/_i18n/zh-cn/documentation/events.md

@@ -94,6 +94,24 @@
         </td>
     </tr>
     <tr>
+        <td>onCheckSome</td>
+        <td>check-some.bs.table</td>
+        <td>rows</td>
+        <td>
+        Fires when user check some rows, the parameters contains: <br>
+        rows: array of records corresponding to previously checked rows.
+        </td>
+    </tr>
+    <tr>
+        <td>onUncheckSome</td>
+        <td>uncheck-some.bs.table</td>
+        <td>rows</td>
+        <td>
+        Fires when user uncheck some rows, the parameters contains: <br>
+        rows: array of records corresponding to previously checked rows.
+        </td>
+    </tr>
+    <tr>
         <td>onLoadSuccess</td>
         <td>load-success.bs.table</td>
         <td>data</td>

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

@@ -108,6 +108,16 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         </td>
     </tr>
     <tr>
+        <td>updateCell</td>
+        <td>params</td>
+        <td>
+        Update one cell, the params contains following properties: <br>
+        rowIndex: the row index. <br>
+        fieldName: the field name.<br>
+        fieldValue: the new field value. <br>
+        </td>
+    </tr>
+    <tr>
         <td>refresh</td>
         <td>params</td>
         <td>Refresh the remote server data, you can set <code>{silent: true}</code> to refresh the data silently, and set <code>{url: newUrl}</code> to change the url. To supply query params specific to this request, set <code>{query: {foo: 'bar'}}</code></td>

+ 23 - 3
src/bootstrap-table.js

@@ -261,10 +261,16 @@
         onUncheck: function (row) {
             return false;
         },
-        onCheckAll: function () {
+        onCheckAll: function (rows) {
             return false;
         },
-        onUncheckAll: function () {
+        onUncheckAll: function (rows) {
+            return false;
+        },
+        onCheckSome: function(rows){
+            return false;
+        },
+        onUncheckSome: function(rows){
             return false;
         },
         onLoadSuccess: function (data) {
@@ -375,6 +381,8 @@
         'uncheck.bs.table': 'onUncheck',
         'check-all.bs.table': 'onCheckAll',
         'uncheck-all.bs.table': 'onUncheckAll',
+        'check-some.bs.table': 'onCheckSome',
+        'uncheck-some.bs.table': 'onUncheckSome',
         'load-success.bs.table': 'onLoadSuccess',
         'load-error.bs.table': 'onLoadError',
         'column-switch.bs.table': 'onColumnSwitch',
@@ -1984,6 +1992,15 @@
         $td.attr('rowspan', rowspan).attr('colspan', colspan).show();
     };
 
+    BootstrapTable.prototype.updateCell = function (params) {
+        if (!params.hasOwnProperty('rowIndex') || !params.hasOwnProperty('fieldName') || !params.hasOwnProperty('fieldValue')) {
+            return;
+        }
+        this.data[params.rowIndex][params.fieldName] = params.fieldValue;
+        this.initSort();
+        this.initBody(true);
+    };
+
     BootstrapTable.prototype.getOptions = function () {
         return this.options;
     };
@@ -2054,7 +2071,8 @@
             return;
         }
 
-        var that = this;
+        var that = this,
+            rows = [];
         $.each(this.options.data, function (index, row) {
             if (!row.hasOwnProperty(obj.field)) {
                 return false;
@@ -2062,10 +2080,12 @@
             if ($.inArray(row[obj.field], obj.values) !== -1) {
                 that.$selectItem.filter(sprintf('[data-index="%s"]', index)).prop('checked', checked);
                 row[that.header.stateField] = checked;
+                rows.push(row);
                 that.trigger(checked ? 'check' : 'uncheck', row);
             }
         });
         this.updateSelected();
+        this.trigger(checked ? 'check-some' : 'uncheck-some', rows);
     };
 
     BootstrapTable.prototype.destroy = function () {