ソースを参照

Merge pull request #4699 from wenzhixin/fix/4685

Fixed filter not work bug with undefined for filter-control extension
Dustin Utecht 6 年 前
コミット
420f9399d5

+ 1 - 0
CHANGELOG.md

@@ -21,6 +21,7 @@ ChangeLog
 - **Update:** Fixed `checkAll` event bug with sortable checkbox field.
 - **Update:** Fixed checkbox and not-found td style errors.
 - **Update:** Fixed `hideUnusedSelectOptions` not work bug for filter-control extension.
+- **Update:** Fixed filter not work bug with `undefined` for filter-control extension.
 - **Update:** Fixed `virtualScroll` option bug with treegrid extension.
 - **Update:** Fixed input keyboard bug for mobile extension.
 - **Update:** Fixed detail view column reorder bug for reorder-columns extension.

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

@@ -691,8 +691,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
     that.data = fp
       ? that.options.data.filter((item, i) => {
         const itemIsExpected = []
-        Object.keys(item).forEach((x, index) => {
-          const key = that.header.fields[index]
+        const keys1 = Object.keys(item)
+        const keys2 = Object.keys(fp)
+        const keys = keys1.concat(keys2.filter(item => !keys1.includes(item)))
+
+        keys.forEach(key => {
           const thisColumn = that.columns[that.fieldsColumnsIndex[key]]
           const fval = (fp[key] || '').toLowerCase()
           let value = Utils.getItemField(item, key, false)