Angular 来自物料表的filterPredicate未在应用程序中工作
我想为我的物料表实现一个客户过滤器,但是当我调试并在这个客户过滤器函数中设置一个断点时。但它不起作用 代码如下所示:Angular 来自物料表的filterPredicate未在应用程序中工作,angular,angular-material,angular-material-table,Angular,Angular Material,Angular Material Table,我想为我的物料表实现一个客户过滤器,但是当我调试并在这个客户过滤器函数中设置一个断点时。但它不起作用 代码如下所示: ngOnInit() { if ( !this.displayedColumns && this.tableData.rows.length > 0 && !this.isFilterAvailable ) { this.displayedColumns = _.keys(_.
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将运行,但FilterFunction将只显示所有数据中的第一行数据
致以最良好的祝愿
Leo我如何重现一个问题?为什么要重写谓词?请参阅此处的帮助,了解如何重现问题?为什么要重新编写谓词?请看这里的帮助