浏览代码

Merge branch 'master' of https://github.com/wenzhixin/bootstrap-table

Conflicts:
	src/bootstrap-table.js
jtrumbull 10 年之前
父节点
当前提交
90bd8b166e

+ 1 - 1
CHANGELOG.md

@@ -1,6 +1,6 @@
 ## ChangeLog
 
-###
+### 1.8.0
 
 - [bug] Fix #672: Column Fixed Width in Percentage bug.
 - [enh] Added state saving for visible columns and the ability to use extension with multiple simultaneous tables.

+ 30 - 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>
@@ -155,5 +173,17 @@
        <td>none</td>
        <td>Fires after the table header is rendered and availble in the DOM</td>
     </tr>
+    <tr>
+        <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>
+    </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>
+    </tr>
     </tbody>
 </table>

+ 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>

+ 14 - 0
docs/_i18n/en/documentation/table-options.md

@@ -332,6 +332,20 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>True to show card view table, for example mobile view.</td>
     </tr>
     <tr>
+        <td>detailView</td>
+        <td>data-detail-view</td>
+        <td>Boolean</td>
+        <td>false</td>
+        <td>True to show detail view table.</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>
+    </tr>
+    <tr>
         <td>searchAlign</td>
         <td>data-search-align</td>
         <td>String</td>

+ 39 - 5
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>
@@ -140,5 +160,19 @@
        <td>none</td>
        <td>Se ejecuta después de que el encabezado es renderizado y disponible en el DOM.</td>
     </tr>
+    <tr>
+        <td>onExpandRow</td>
+        <td>expand-row.bs.table</td>
+        <td>index, row, $detail</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>Se ejecuta cuando se da click al icono de detalle para colapsar la vista detalle.</td>
+    </tr>
+    </tbody>
+</table>
     </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>

+ 14 - 0
docs/_i18n/es/documentation/table-options.md

@@ -315,6 +315,20 @@ Las opciones de la tabla están definidas en `jQuery.fn.bootstrapTable.defaults`
         <td>True para mostrar la vista de tarjeta, por ejemplo en móviles.</td>
     </tr>
     <tr>
+        <td>detailView</td>
+        <td>data-detail-view</td>
+        <td>Boolean</td>
+        <td>false</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>Formatee su vista detalle cuando <code>detailView</code> está seteada en <code>true</code>.</td>
+    </tr>
+    <tr>
         <td>searchAlign</td>
         <td>data-search-align</td>
         <td>String</td>

+ 32 - 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>
@@ -155,5 +173,19 @@
        <td>none</td>
        <td>Fires after the table header is rendered and availble in the DOM</td>
     </tr>
+    <tr>
+        <td>onExpandRow</td>
+        <td>expand-row.bs.table</td>
+        <td>index, row, $detail</td>
+        <td>当点击详细图标展开详细页面的时候触发。</td>
+    </tr>
+    <tr>
+       <td>onCollapseRow</td>
+       <td>collapse-row.bs.table</td>
+       <td>index, row</td>
+       <td>当点击详细图片收起详细页面的时候触发。</td>
+    </tr>
+    </tbody>
+</table>
     </tbody>
 </table>

+ 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>

+ 14 - 0
docs/_i18n/zh-cn/documentation/table-options.md

@@ -332,6 +332,20 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>True to show card view table, for example mobile view.</td>
     </tr>
     <tr>
+        <td>detailView</td>
+        <td>data-detail-view</td>
+        <td>Boolean</td>
+        <td>false</td>
+        <td>设置为 True 可以显示详细页面模式。</td>
+    </tr>
+    <tr>
+        <td>detailFormatter</td>
+        <td>data-detail-formatter</td>
+        <td>Function</td>
+        <td>function(index, row) {<br>return '';<br>}</td>
+        <td>格式化详细页面模式的视图。</td>
+    </tr>
+    <tr>
         <td>searchAlign</td>
         <td>data-search-align</td>
         <td>String</td>

+ 3 - 1
docs/extensions.md

@@ -25,4 +25,6 @@ lead: pages.extensions.lead
 
 {% tf extensions/filtercontrol.md %}
 
-{% tf extensions/naturalsorting.md %}
+{% tf extensions/naturalsorting.md %}
+
+{% tf extensions/toolbar.md %}

+ 4 - 0
src/bootstrap-table.css

@@ -96,6 +96,10 @@
     padding-right: 30px;
 }
 
+.fixed-table-container th.detail {
+    width: 30px;
+}
+
 .fixed-table-container tbody td {
     border-left: 1px solid #dddddd;
 }

+ 4 - 27
src/bootstrap-table.js

@@ -242,12 +242,6 @@
         onAll: function (name, args) {
             return false;
         },
-        onClickCell: function (field, value, row, $element) {
-            return false;
-        },
-        onDblClickCell: function (field, value, row, $element) {
-            return false;
-        },
         onClickRow: function (item, $element) {
             return false;
         },
@@ -370,8 +364,6 @@
 
     BootstrapTable.EVENTS = {
         'all.bs.table': 'onAll',
-        'click-cell.bs.table': 'onClickCell',
-        'dbl-click-cell.bs.table': 'onDblClickCell',
         'click-row.bs.table': 'onClickRow',
         'dbl-click-row.bs.table': 'onDblClickRow',
         'sort.bs.table': 'onSort',
@@ -1364,15 +1356,8 @@
 
         // click to select by column
         this.$body.find('> tr > td').off('click').on('click', function () {
-            var $td = $(this),
-                $tr = $td.parent(),
-                item = that.data[$tr.data('index')],
-                cellIndex = $td[0].cellIndex,
-                $headerCell = that.$header.find('th:eq(' + cellIndex + ')'),
-                field = $headerCell.data('field'),
-                value = item[field];
-            that.trigger('click-cell', field, value, item, $td);
-            that.trigger('click-row', item, $tr);
+            var $tr = $(this).parent();
+            that.trigger('click-row', that.data[$tr.data('index')], $tr);
             // if click to select - then trigger the checkbox/radio click
             if (that.options.clickToSelect) {
                 if (that.header.clickToSelects[$tr.children().index($(this))]) {
@@ -1381,16 +1366,8 @@
                 }
             }
         });
-        this.$body.find('> tr > td').off('dblclick').on('dblclick', function () {
-            var $td = $(this),
-                $tr = $td.parent(),
-                item = that.data[$tr.data('index')],
-                cellIndex = $td[0].cellIndex,
-                $headerCell = that.$header.find('th:eq(' + cellIndex + ')'),
-                field = $headerCell.data('field'),
-                value = item[field];
-            that.trigger('dbl-click-cell', field, value, item, $td);
-            that.trigger('dbl-click-row', item, $tr);
+        this.$body.find('tr').off('dblclick').on('dblclick', function () {
+            that.trigger('dbl-click-row', that.data[$(this).data('index')], $(this));
         });
 
         this.$selectItem = this.$body.find(sprintf('[name="%s"]', this.options.selectItemName));

+ 24 - 0
src/extensions/cookie/bootstrap-table-cookie.js

@@ -107,6 +107,10 @@
         _onSort = BootstrapTable.prototype.onSort,
         _onPageNumber = BootstrapTable.prototype.onPageNumber,
         _onPageListChange = BootstrapTable.prototype.onPageListChange,
+        _onPageFirst = BootstrapTable.prototype.onPageFirst,
+        _onPagePre = BootstrapTable.prototype.onPagePre,
+        _onPageNext = BootstrapTable.prototype.onPageNext,
+        _onPageLast = BootstrapTable.prototype.onPageLast,
         _toggleColumn = BootstrapTable.prototype.toggleColumn,
         _onSearch = BootstrapTable.prototype.onSearch;
 
@@ -180,6 +184,26 @@
         setCookie(this, idsStateSaveList.pageList, this.options.pageSize);
     };
 
+    BootstrapTable.prototype.onPageFirst = function () {
+        _onPageFirst.apply(this, Array.prototype.slice.apply(arguments));
+        setCookie(this, idsStateSaveList.pageNumber, this.options.pageNumber);
+    };
+
+    BootstrapTable.prototype.onPagePre = function () {
+        _onPagePre.apply(this, Array.prototype.slice.apply(arguments));
+        setCookie(this, idsStateSaveList.pageNumber, this.options.pageNumber);
+    };
+
+    BootstrapTable.prototype.onPageNext = function () {
+        _onPageNext.apply(this, Array.prototype.slice.apply(arguments));
+        setCookie(this, idsStateSaveList.pageNumber, this.options.pageNumber);
+    };
+
+    BootstrapTable.prototype.onPageLast = function () {
+        _onPageLast.apply(this, Array.prototype.slice.apply(arguments));
+        setCookie(this, idsStateSaveList.pageNumber, this.options.pageNumber);
+    };
+
     BootstrapTable.prototype.toggleColumn = function () {
         _toggleColumn.apply(this, Array.prototype.slice.apply(arguments));