我想为我的物料表实现一个客户过滤器,但是当我调试并在此客户过滤器功能中设置一个断点时。但它不起作用。
代码是这样的:
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将仅显示所有数据中的第一行数据
最好的问候,
狮子座