Browse Source

Fixed filter not work bug with undefined for filter-control extension

zhixin 6 years ago
parent
commit
7a41821d9e
2 changed files with 6 additions and 2 deletions
  1. 1 0
      CHANGELOG.md
  2. 5 2
      src/extensions/filter-control/bootstrap-table-filter-control.js

+ 1 - 0
CHANGELOG.md

@@ -21,6 +21,7 @@ ChangeLog
 - **Update:** Fixed `checkAll` event bug with sortable checkbox field.
 - **Update:** Fixed `checkAll` event bug with sortable checkbox field.
 - **Update:** Fixed checkbox and not-found td style errors.
 - **Update:** Fixed checkbox and not-found td style errors.
 - **Update:** Fixed `hideUnusedSelectOptions` not work bug for filter-control extension.
 - **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 `virtualScroll` option bug with treegrid extension.
 - **Update:** Fixed input keyboard bug for mobile extension.
 - **Update:** Fixed input keyboard bug for mobile extension.
 - **Update:** Fixed detail view column reorder bug for reorder-columns 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.data = fp
       ? that.options.data.filter((item, i) => {
       ? that.options.data.filter((item, i) => {
         const itemIsExpected = []
         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 thisColumn = that.columns[that.fieldsColumnsIndex[key]]
           const fval = (fp[key] || '').toLowerCase()
           const fval = (fp[key] || '').toLowerCase()
           let value = Utils.getItemField(item, key, false)
           let value = Utils.getItemField(item, key, false)