Browse Source

Merge pull request #367 from tristanlee85/master

Allow query params to be specified during refresh
文翼 11 years ago
parent
commit
f8cadc5c47
2 changed files with 4 additions and 4 deletions
  1. 1 1
      docs/_i18n/en/documentation/methods.md
  2. 3 3
      src/bootstrap-table.js

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

@@ -69,7 +69,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.</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>{queryparams: {foo: 'bar'}}</code></td>
     </tr>
     <tr>
         <td>showLoading</td>

+ 3 - 3
src/bootstrap-table.js

@@ -1142,7 +1142,7 @@
         this.trigger('post-body');
     };
 
-    BootstrapTable.prototype.initServer = function (silent) {
+    BootstrapTable.prototype.initServer = function (silent, queryparams) {
         var that = this,
             data = {},
             params = {
@@ -1166,7 +1166,7 @@
                 order: params.sortOrder
             };
         }
-        data = calculateObjectValue(this.options, this.options.queryParams, [params], data);
+        data = calculateObjectValue(this.options, $.extend(this.options.queryParams, queryparams || {}), [params], data);
 
         // false to stop request
         if (data === false) {
@@ -1493,7 +1493,7 @@
             this.options.url = params.url;
             this.options.pageNumber = 1;
         }
-        this.initServer(params && params.silent);
+        this.initServer(params && params.silent, params && params.queryparams);
     };
 
     BootstrapTable.prototype.showColumn = function (field) {