浏览代码

Merge pull request #4858 from wenzhixin/fix/4463

fixed filtercontrol with fixed-column
文翼 5 年之前
父节点
当前提交
f17ab43976
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      src/extensions/fixed-columns/bootstrap-table-fixed-columns.js

+ 19 - 0
src/extensions/fixed-columns/bootstrap-table-fixed-columns.js

@@ -327,5 +327,24 @@ $.BootstrapTable = class extends $.BootstrapTable {
         }
       })
     }
+
+    if (this.options.filterControl) {
+      $(this.$fixedColumns).off('keyup change').on('keyup change', e => {
+        const $target = $(e.target)
+        const value = $target.val()
+        const field = $target.parents('th').data('field')
+        const $coreTh = this.$header.find(`th[data-field="${field}"]`)
+
+        if ($target.is('input')) {
+          $coreTh.find('input').val(value)
+        } else if ($target.is('select')) {
+          const $select = $coreTh.find('select')
+          $select.find('option[selected]').removeAttr('selected')
+          $select.find(`option[value="${value}"]`).attr('selected', true)
+        }
+
+        this.triggerSearch()
+      })
+    }
   }
 }