Browse Source

Change data-url using refresh:url (#2891)

feat(js): add 'pageNumber' and 'pageSize' to 'refresh' method
Jack Sheppard 8 years ago
parent
commit
cd8ab111d3
2 changed files with 9 additions and 1 deletions
  1. 1 1
      docs/_i18n/en/documentation/methods.md
  2. 8 0
      src/bootstrap-table.js

+ 1 - 1
docs/_i18n/en/documentation/methods.md

@@ -180,7 +180,7 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
     <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>
+        <td>Refresh the remote server data, you can set <code>{silent: true}</code> to refresh the data silently, and set <code>{url: newUrl, pageNumber: pageNumber, pageSize: pageSize}</code> to change the url (optional), page number (optional) and page size (optional). To supply query params specific to this request, set <code>{query: {foo: 'bar'}}</code>.</td>
     </tr>
     <tr>
         <td>refreshOptions</td>

+ 8 - 0
src/bootstrap-table.js

@@ -2761,8 +2761,16 @@
 
     BootstrapTable.prototype.refresh = function (params) {
         if (params && params.url) {
+            this.options.url = params.url;
+        }
+        if (params && params.pageNumber) {
+            this.options.pageNumber = params.pageNumber;
+        } else {
             this.options.pageNumber = 1;
         }
+        if (params && params.pageSize) {
+            this.options.pageSize = params.pageSize;
+        }
         this.initServer(params && params.silent,
             params && params.query, params && params.url);
         this.trigger('refresh', params);