浏览代码

Improvements for multi-select on filter control rework (#5736)

* Fix attribute name to enable multi select filter

* Standardize attribute name and var for multi select options

* Do not add empty option on multiple select
Alberto Fanjul 4 年之前
父节点
当前提交
9d851b18f2

+ 4 - 4
site/docs/extensions/filter-control.md

@@ -196,7 +196,7 @@ Dependence if you use the multipleSelect option: [multiple-select](https://multi
 
 ### filterControlMultipleSelect
 
-- **Attribute:** `data-filter-multiple-select`
+- **Attribute:** `data-filter-control-multiple-select`
 
 - **type:** `boolean`
 
@@ -206,15 +206,15 @@ Dependence if you use the multipleSelect option: [multiple-select](https://multi
 
 - **Default:** `false`
 
-### filterMultipleSelectOptions
+### filterControlMultipleSelectOptions
 
-- **Attribute:** `data-filter-multiple-select-options`
+- **Attribute:** `data-filter-control-multiple-select-options`
 
 - **type:** `Object`
 
 - **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}'`. See this [documentation](https://multiple-select.wenzhixin.net.cn/docs/en/options)
+   If the filterControlMultipleSelect option is set to true, use this option to configure the select with the native options. Use this way: `data-filter-control-multiple-select-options='{"property1":value1, "property2": value2, "property3": value3}'`. See this [documentation](https://multiple-select.wenzhixin.net.cn/docs/en/options)
 
 - **Default:** `undefined`
 

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

@@ -62,7 +62,7 @@ $.extend($.fn.bootstrapTable.defaults, {
 $.extend($.fn.bootstrapTable.columnDefaults, {
   filterControl: undefined, // input, select, datepicker
   filterControlMultipleSelect: false,
-  filterMultipleSelectOptions: {},
+  filterControlMultipleSelectOptions: {},
   filterDataCollector: undefined,
   filterData: undefined,
   filterDatepickerOptions: {},
@@ -147,7 +147,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
               const multipleSelects = container.find('.fc-multipleselect')
 
               if (multipleSelects.length > 0 && $.fn.multipleSelect) {
-                multipleSelects.multipleSelect('destroy').multipleSelect(this.options.filterMultipleSelectOptions)
+                multipleSelects.multipleSelect('destroy').multipleSelect(this.options.filterControlMultipleSelectOptions)
               }
             }, 2)
           }, 2)

+ 1 - 1
src/extensions/filter-control/utils.js

@@ -244,7 +244,7 @@ export function initFilterSelectControls (that) {
     const selectControl = getControlContainer(that).find(`select.bootstrap-table-filter-control-${escapeID(column.field)}`)
 
     if (isColumnSearchableViaSelect(column) && isFilterDataNotGiven(column) && hasSelectControlElement(selectControl)) {
-      if (selectControl.get(selectControl.length - 1).options.length === 0) {
+      if (!selectControl[0].multiple && selectControl.get(selectControl.length - 1).options.length === 0) {
         // Added the default option, must use a non-breaking space( ) to pass the W3C validator
         addOptionToSelectControl(selectControl, '', column.filterControlPlaceholder || ' ', column.filterDefault)
       }