浏览代码

Added refresh-options method

Fix #799 is there a direct method to change the number of records per
page ?
Example: http://jsfiddle.net/djhvscf/e3nk137y/1878/
Dennis Hernández 10 年之前
父节点
当前提交
44a9aa317e

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

@@ -209,5 +209,11 @@
        <td>index, row</td>
        <td>index, row</td>
        <td>Fires when click the detail icon to collapse the detail view.</td>
        <td>Fires when click the detail icon to collapse the detail view.</td>
     </tr>
     </tr>
+    <tr>
+       <td>onRefreshOptions</td>
+       <td>refresh-options.bs.table</td>
+       <td>options</td>
+       <td>Fires after refresh the options and before destroy and init the table</td>
+    </tr>
     </tbody>
     </tbody>
 </table>
 </table>

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

@@ -144,6 +144,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <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>
         <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>
     </tr>
     </tr>
     <tr>
     <tr>
+        <td>refreshOptions</td>
+        <td>options</td>
+        <td>Refresh the options</td>
+    </tr>
+    <tr>
         <td>showLoading</td>
         <td>showLoading</td>
         <td>none</td>
         <td>none</td>
         <td>Show loading status.</td>
         <td>Show loading status.</td>

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

@@ -196,5 +196,11 @@
        <td>index, row</td>
        <td>index, row</td>
        <td>Se ejecuta cuando se da click al icono de detalle para colapsar la vista detalle.</td>
        <td>Se ejecuta cuando se da click al icono de detalle para colapsar la vista detalle.</td>
     </tr>
     </tr>
+    <tr>
+       <td>onRefreshOptions</td>
+       <td>refresh-options.bs.table</td>
+       <td>options</td>
+       <td>Se ejecuta cuando se actualiza el objeto options, este método se ejecuta antes de los eventos destroy e init</td>
+    </tr>
     </tbody>
     </tbody>
 </table>
 </table>

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

@@ -140,6 +140,11 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
         <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>
         <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>
     </tr>
     </tr>
     <tr>
     <tr>
+        <td>refreshOptions</td>
+        <td>options</td>
+        <td>Actualiza el objecto options</td>
+    </tr>
+    <tr>
         <td>showLoading</td>
         <td>showLoading</td>
         <td>none</td>
         <td>none</td>
         <td>Mostrar el estado de la carga.</td>
         <td>Mostrar el estado de la carga.</td>

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

@@ -209,5 +209,11 @@
        <td>index, row</td>
        <td>index, row</td>
        <td>当点击详细图片收起详细页面的时候触发。</td>
        <td>当点击详细图片收起详细页面的时候触发。</td>
     </tr>
     </tr>
+    <tr>
+       <td>onRefreshOptions</td>
+       <td>refresh-options.bs.table</td>
+       <td>options</td>
+       <td>Fires after refresh the options and before destroy and init the table</td>
+    </tr>
     </tbody>
     </tbody>
 </table>
 </table>

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

@@ -123,6 +123,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <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>
         <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>
     </tr>
     </tr>
     <tr>
     <tr>
+        <td>refreshOptions</td>
+        <td>options</td>
+        <td>Refresh the options</td>
+    </tr>
+    <tr>
         <td>showLoading</td>
         <td>showLoading</td>
         <td>none</td>
         <td>none</td>
         <td>Show loading status.</td>
         <td>Show loading status.</td>

+ 14 - 2
src/bootstrap-table.js

@@ -316,6 +316,9 @@
         },
         },
         onCollapseRow: function (index, row) {
         onCollapseRow: function (index, row) {
             return false;
             return false;
+        },
+        onRefreshOptions: function (options) {
+            return false;
         }
         }
     };
     };
 
 
@@ -406,7 +409,8 @@
         'post-body.bs.table': 'onPostBody',
         'post-body.bs.table': 'onPostBody',
         'post-header.bs.table': 'onPostHeader',
         'post-header.bs.table': 'onPostHeader',
         'expand-row.bs.table': 'onExpandRow',
         'expand-row.bs.table': 'onExpandRow',
-        'collapse-row.bs.table': 'onCollapseRow'
+        'collapse-row.bs.table': 'onCollapseRow',
+        'refresh-options.bs.table': 'onRefreshOptions'
     };
     };
 
 
     BootstrapTable.prototype.init = function () {
     BootstrapTable.prototype.init = function () {
@@ -2224,6 +2228,13 @@
         this.trigger('toggle', this.options.cardView);
         this.trigger('toggle', this.options.cardView);
     };
     };
 
 
+    BootstrapTable.prototype.refreshOptions = function (options) {
+        this.options = $.extend(this.options, options);
+        this.trigger('refresh-options', this.options);
+        this.destroy();
+        this.init();
+    };
+
     // BOOTSTRAP TABLE PLUGIN DEFINITION
     // BOOTSTRAP TABLE PLUGIN DEFINITION
     // =======================
     // =======================
 
 
@@ -2248,7 +2259,8 @@
         'getScrollPosition',
         'getScrollPosition',
         'selectPage', 'prevPage', 'nextPage',
         'selectPage', 'prevPage', 'nextPage',
         'togglePagination',
         'togglePagination',
-        'toggleView'
+        'toggleView',
+        'refreshOptions'
     ];
     ];
 
 
     $.fn.bootstrapTable = function (option) {
     $.fn.bootstrapTable = function (option) {