Browse Source

Fixing PR comments

djhvscf 4 years ago
parent
commit
7406e0b5de

+ 5 - 15
site/docs/extensions/filter-control.md

@@ -6,6 +6,8 @@ group: extensions
 toc: true
 ---
 
+Dependence if you use the multipleSelect option: [multiple-select](https://multiple-select.wenzhixin.net.cn/) >= v1.5.2
+
 ## Usage
 
 {% highlight html %}
@@ -126,7 +128,7 @@ toc: true
 
 - **Detail:**
 
-   Set `input`: show an input control, `select`: show a select control, `multipleselect`: show an advance select control. This options has a dependency with [multiple-select](http://multiple-select.wenzhixin.net.cn/examples) library, `datepicker`: show a html5 datepicker control.
+   Set `input`: show an input control, `select`: show a select control, `datepicker`: show a html5 datepicker control.
 
 - **Default:** `undefined`
 
@@ -188,7 +190,7 @@ toc: true
 
 - **Detail:**
 
-   If the datepicker option is set use this option to configure the datepicker with the native options. Use this way: `data-filter-datepicker-options='{"property1":value1, "property2": value2, "property3": value3}'`.
+   If the datepicker option is set use this option to configure the datepicker with the native options. Use this way: `data-filter-datepicker-options='{"max":value1, "min": value2, "step": value3}'`. For more information visit this [documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date)
 
 - **Default:** `undefined`
 
@@ -204,18 +206,6 @@ toc: true
 
 - **Default:** `false`
 
-### filterControlMultipleSelectMultiple
-
-- **Attribute:** `data-filter-multiple-select-multiple`
-
-- **type:** `boolean`
-
-- **Detail:**
-
-   If the filterControlMultipleSelect option is set to true, use this option to configure the select as multiple select.
-
-- **Default:** `false`
-
 ### filterMultipleSelectOptions
 
 - **Attribute:** `data-filter-multiple-select-options`
@@ -224,7 +214,7 @@ toc: true
 
 - **Detail:**
 
-   If the filterControlMultipleSelect option is set to true, use this option to configure the select with the native options. Use this way: `data-filter-multiple-select-options='{"property1":value1, "property2": value2, "property3": value3}'`.
+   If the filterControlMultipleSelect option is set to true, use this option to configure the select with the native options. Use this way: `data-filter-multiple-select-options='{"property1":value1, "property2": value2, "property3": value3}'`. See this [documentation](https://multiple-select.wenzhixin.net.cn/docs/en/options)
 
 - **Default:** `undefined`
 

+ 3 - 4
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -35,7 +35,7 @@ $.extend($.fn.bootstrapTable.defaults, {
         UtilsFilterControl.getFormControlClass(options),
         column.field,
         column.filterControlMultipleSelect ? 'fc-multipleselect' : '',
-        column.filterControlMultipleSelectMultiple ? 'multiple="multiple"' : '',
+        column.filterControlMultipleSelect ? 'multiple="multiple"' : '',
         UtilsFilterControl.getDirectionOfSelectOptions(
           options.alignmentSelectControlOptions
         )
@@ -62,7 +62,6 @@ $.extend($.fn.bootstrapTable.defaults, {
 $.extend($.fn.bootstrapTable.columnDefaults, {
   filterControl: undefined, // input, select, datepicker
   filterControlMultipleSelect: false,
-  filterControlMultipleSelectMultiple: false,
   filterMultipleSelectOptions: {},
   filterDataCollector: undefined,
   filterData: undefined,
@@ -148,8 +147,8 @@ $.BootstrapTable = class extends $.BootstrapTable {
               const container = UtilsFilterControl.getControlContainer(this)
               const multipleSelects = container.find('.fc-multipleselect')
 
-              if (multipleSelects.length > 0) {
-                multipleSelects.multipleSelect('destroy').multipleSelect()
+              if (multipleSelects.length > 0 && $.fn.multipleSelect) {
+                multipleSelects.multipleSelect('destroy').multipleSelect(this.options.filterMultipleSelectOptions)
               }
             }, 2)
           }, 2)

+ 10 - 2
src/extensions/filter-control/utils.js

@@ -191,7 +191,15 @@ export function setValues (that) {
                 element.focus()
               }
 
-              element.value = cacheElementInfo.value
+              if (Array.isArray(cacheElementInfo.value)) {
+                const $element = $(element)
+
+                $.each(cacheElementInfo.value, function (i, e) {
+                  $element.find(Utils.sprintf('option[value=\'%s\']', e)).prop('selected', true)
+                })
+              } else {
+                element.value = cacheElementInfo.value
+              }
               setCaretPosition(element, cacheElementInfo.position)
             }
 
@@ -225,7 +233,7 @@ export function isFilterDataNotGiven ({ filterData }) {
 }
 
 export function hasSelectControlElement (selectControl) {
-  return selectControl && selectControl.length > 0 // && selectControl.get(selectControl.length - 1).options.length === 0
+  return selectControl && selectControl.length > 0
 }
 
 export function initFilterSelectControls (that) {