Browse Source

Set the formattedValue as value if serachFormatter is true

NAME 5 years ago
parent
commit
7fef7fbab9
1 changed files with 5 additions and 6 deletions
  1. 5 6
      src/extensions/filter-control/bootstrap-table-filter-control.js

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

@@ -67,9 +67,7 @@ const UtilsFilterControl = {
     $selectControl.append($opts)
   },
   existOptionInSelectControl (selectControl, value) {
-    const options = UtilsFilterControl.getOptionsFromSelectControl(
-      selectControl
-    )
+    const options = UtilsFilterControl.getOptionsFromSelectControl(selectControl)
     for (let i = 0; i < options.length; i++) {
       if (options[i].value === value.toString()) {
         // The value is not valid to add
@@ -245,7 +243,7 @@ const UtilsFilterControl = {
         const uniqueValues = {}
         for (let i = 0; i < z; i++) {
           // Added a new value
-          const fieldValue = data[i][field]
+          let fieldValue = data[i][field]
           const formatter = that.options.editable && column.editable ? column._formatter : that.header.formatters[j]
           let formattedValue = Utils.calculateObjectValue(that.header, formatter, [fieldValue, data[i], i], fieldValue)
 
@@ -253,10 +251,12 @@ const UtilsFilterControl = {
             formattedValue = Utils.calculateObjectValue(that.header, column.filterDataCollector, [fieldValue, data[i], formattedValue], formattedValue)
           }
 
+          if (column.searchFormatter) {
+            fieldValue = formattedValue
+          }
           uniqueValues[formattedValue] = fieldValue
 
           if (typeof formattedValue === 'object' && formattedValue !== null) {
-
             formattedValue.forEach((value) => {
               UtilsFilterControl.addOptionToSelectControl(selectControl, value, value, column.filterDefault)
             })
@@ -269,7 +269,6 @@ const UtilsFilterControl = {
         }
 
         UtilsFilterControl.sortSelectControl(selectControl, column.filterOrderBy)
-
         if (that.options.hideUnusedSelectOptions) {
           UtilsFilterControl.hideUnusedSelectOptions(selectControl, uniqueValues)
         }