Browse Source

Fix #2427

Added option in order to disabled the control while the server is responding the data
Dennis Hernández 8 years ago
parent
commit
789116891d

+ 6 - 0
src/extensions/filter-control/README.md

@@ -36,6 +36,12 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith
 * description: Set to true in order to hide the options that are not in the table. This option does not work on server-side pagination.
 * description: Set to true in order to hide the options that are not in the table. This option does not work on server-side pagination.
 * default: `false`
 * default: `false`
 
 
+### disableControlWhenSearch
+
+* type: Boolean
+* description: Set to true if you want to disable the control while the server is responding the data. This options will work if the sidePagination is 'server'.
+* default: `false`
+
 ## Column options
 ## Column options
 
 
 ### filterControl
 ### filterControl

+ 19 - 0
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -441,6 +441,7 @@
                 return sprintf('<input type="text" class="form-control date-filter-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s">', field, isVisible);
                 return sprintf('<input type="text" class="form-control date-filter-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s">', field, isVisible);
             }
             }
         },
         },
+        disableControlWhenSearch: false,
         //internal variables
         //internal variables
         valuesFilterControl: []
         valuesFilterControl: []
     });
     });
@@ -514,6 +515,10 @@
                 }
                 }
             }).on('column-switch.bs.table', function() {
             }).on('column-switch.bs.table', function() {
                 setValues(that);
                 setValues(that);
+            }).on('load-success.bs.table', function() {
+                that.EnableControls(true);
+            }).on('load-error.bs.table', function() {
+                that.EnableControls(true);
             });
             });
         }
         }
         _init.apply(this, Array.prototype.slice.apply(arguments));
         _init.apply(this, Array.prototype.slice.apply(arguments));
@@ -643,6 +648,7 @@
         this.searchText += "randomText";
         this.searchText += "randomText";
 
 
         this.options.pageNumber = 1;
         this.options.pageNumber = 1;
+        this.EnableControls(false);
         this.onSearch(event);
         this.onSearch(event);
         this.trigger('column-search', $field, text);
         this.trigger('column-search', $field, text);
     };
     };
@@ -713,4 +719,17 @@
             }
             }
         });
         });
     };
     };
+
+    BootstrapTable.prototype.EnableControls = function(enable) {
+        if((this.options.disableControlWhenSearch) && (this.options.sidePagination === 'server')) {
+            var header = getCurrentHeader(this),
+            searchControls = getCurrentSearchControls(this);
+
+            if(!enable) {
+                header.find(searchControls).prop('disabled', 'disabled');
+            } else {
+                header.find(searchControls).removeProp('disabled');
+            }
+        }
+    };
 })(jQuery);
 })(jQuery);