ソースを参照

Instead of disable, hide the option

Dennis Hernández 9 年 前
コミット
9599519928

+ 2 - 2
src/extensions/filter-control/README.md

@@ -30,10 +30,10 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith
 * description: Set the alignemnt of the select control options. Use Use `left`, `right` or `auto`.
 * default: `undefined`
 
-### disableUnusedSelectOptions
+### hideUnusedSelectOptions
 
 * type: Boolean
-* description: Set to true in order to disable 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`
 
 ## Column options

+ 1 - 5
src/extensions/filter-control/bootstrap-table-filter-control.css

@@ -3,15 +3,11 @@
  * @webSite: http://djhvscf.github.io/Blog
  * @version: v2.1.2
  */
- 
+
 .no-filter-control {
     height: 34px;
 }
 
 .filter-control {
     margin: 0 2px 2px 2px;
-}
-
-select option:disabled {
-    background-color: #f2f2f2;
 }

+ 5 - 5
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -15,15 +15,15 @@
         return selectControl.get(selectControl.length - 1).options;
     };
 
-    var disableOptionSelectControl = function (selectControl, uniqueValues) {
+    var hideUnusedSelectOptions = function (selectControl, uniqueValues) {
         var options = getOptionsFromSelectControl(selectControl);
 
         for (var i = 0; i < options.length; i++) {
             if (options[i].value !== "") {
                 if (!uniqueValues.hasOwnProperty(options[i].value)) {
-                    selectControl.find(sprintf("option[value='%s']", options[i].value)).attr("disabled", "disabled"); 
+                    selectControl.find(sprintf("option[value='%s']", options[i].value)).css("display", "none"); 
                 } else {
-                    selectControl.find(sprintf("option[value='%s']", options[i].value)).removeAttr("disabled"); 
+                    selectControl.find(sprintf("option[value='%s']", options[i].value)).css("display", "block"); 
                 }
             }
         }
@@ -223,8 +223,8 @@
 
                 sortSelectControl(selectControl);
 
-                if (that.options.disableUnusedSelectOptions) {
-                    disableOptionSelectControl(selectControl, uniqueValues);
+                if (that.options.hideUnusedSelectOptions) {
+                    hideUnusedSelectOptions(selectControl, uniqueValues);
                 }
             }
         });