我想为我的材料表实现一个客户过滤器,但是当我调试并在这个客户过滤器函数中设置一个断点时。但它不起作用。
代码是这样的:
ngOnInit() {
if (
!this.displayedColumns &&
this.tableData.rows.length > 0 &&
!this.isFilterAvailable
) {
this.displayedColumns = _.keys(_.first(this.tableData.rows));
} else {
this.dataSource.data = this.tableData.rows;
this.initFilterValues(_.keys(_.first(this.tableData.rows)));
this.dataSource.filterPredicate = this.createFilter();
}
this.dataSource.data = this.tableData.rows;
this.dataSource.filterPredicate = (data, filter) => {
console.log(data + "hier hier hier");
return true;
};
}
initFilterValues(values) {
values.forEach(key => {
this.filters[key] = "";
});
}
doFilter(filterValue: string, column: string) {
this.filters[column] = filterValue.trim().toLocaleLowerCase();
this.dataSource.filter = JSON.stringify(this.filters);
this.dataSource.filterPredicate = (data, filter) => {
console.log(data + "asdfasdfa");
return true;
};
}
createFilter() {
console.log("create asdfasdfasdfasdfasdf");
const filterFunction = function(data, filter): boolean {
console.log("Function excuted" + data);
let searchTerms = JSON.parse(filter);
return true;
};
return filterFunction;
}
}
在 HTML 中有一个输入字段,如果我提示搜索,doFilter 将运行,但 filterFunktion 将仅显示所有数据中的第一行数据
此致,
狮子座