浏览代码

queryParams return false to stop request.

zhixin 11 年之前
父节点
当前提交
dd95364802
共有 3 个文件被更改,包括 12 次插入6 次删除
  1. 1 1
      README.md
  2. 2 2
      docs/docs.js
  3. 9 3
      src/bootstrap-table.js

+ 1 - 1
README.md

@@ -26,7 +26,7 @@ The table displays data in a tabular format and offers rich support to radio, ch
 - [x] Support search without data-field set.
 - [x] Support search without data-field set.
 - [x] Fix #81: Allow the `class` to be applied to the radio or checkbox row.
 - [x] Fix #81: Allow the `class` to be applied to the radio or checkbox row.
 - [x] Fix #135, #142: Search use formatted data.
 - [x] Fix #135, #142: Search use formatted data.
-- [ ] Verify search text before send queryParams.
+- [x] Verify search text before send queryParams.
 
 
 ## Features
 ## Features
 
 

+ 2 - 2
docs/docs.js

@@ -190,8 +190,8 @@ $(function () {
                     name: 'queryParams',
                     name: 'queryParams',
                     attribute: 'data-query-params',
                     attribute: 'data-query-params',
                     type: 'Function',
                     type: 'Function',
-                    description: 'When request remote data, sending additional parameters by format the queryParams, the parameters object contains: <br>pageSize, pageNumber, searchText, sortName, sortOrder.',
-                    description_zh: '远程数据请求时,可以通过queryParams来格式化所需要的数据信息,参数(对象)包含了:<br>pageSize, pageNumber, searchText, sortName, sortOrder。',
+                    description: 'When request remote data, sending additional parameters by format the queryParams, the parameters object contains: <br>pageSize, pageNumber, searchText, sortName, sortOrder. Return false to stop request',
+                    description_zh: '远程数据请求时,可以通过queryParams来格式化所需要的数据信息,参数(对象)包含了:<br>pageSize, pageNumber, searchText, sortName, sortOrder。返回 false 可以禁用请求。',
                     'default': 'function(params) {<br>return params;<br>}',
                     'default': 'function(params) {<br>return params;<br>}',
                     example: 'server-side-pagination-table'
                     example: 'server-side-pagination-table'
                 },
                 },

+ 9 - 3
src/bootstrap-table.js

@@ -987,9 +987,6 @@
         if (!this.options.url) {
         if (!this.options.url) {
             return;
             return;
         }
         }
-        if (!silent) {
-            this.$loading.show();
-        }
 
 
         if (this.options.queryParamsType === 'limit') {
         if (this.options.queryParamsType === 'limit') {
             params = {
             params = {
@@ -1002,6 +999,15 @@
         }
         }
         data = calculateFunctionValue(this.options, this.options.queryParams, [params], data);
         data = calculateFunctionValue(this.options, this.options.queryParams, [params], data);
 
 
+        // false to stop request
+        if (data === false) {
+            return;
+        }
+
+        if (!silent) {
+            this.$loading.show();
+        }
+
         $.ajax({
         $.ajax({
             type: this.options.method,
             type: this.options.method,
             url: this.options.url,
             url: this.options.url,