加载页面时,我需要默认检查一些过滤条件。我已经通过this.$refs.tableRC.columns.filteredValue = this.filteredBranch设置了默认值,但是我不知道如何手动调用filterHandler()来过滤表数据?
<el-table ref="tableRC" :data="datalist" @filter-change="tableFilter">
<el-table-column label="Branch" :filters="branches" :column-key="'branch'" :filter-method="filterHandler">.
tableFilter(filters) {
this.filteredBranch = filters.branch
},
filterHandler(value, row, column) {
return row.branch === value
},
getReqList() {
....
this.$refs.tableRC.columns[0].filteredValue = this.filteredBranch
....
}发布于 2020-02-26 20:22:24
最后,我找到了解决方案
if (Object.prototype.toString.call(this.filteredBranch) === '[object Array]') {
this.$refs.tableRC.columns[x].filteredValue = this.filteredBranch
this.$refs.tableRC.store.states.columns.forEach(column=> {
if (column.filteredValue && column.filteredValue.length) {
this.$refs.tableRC.store.commit('filterChange', {
column,
values: column.filteredValue,
silent: true
})
}
})
}https://stackoverflow.com/questions/60410310
复制相似问题