gpt4 book ai didi

angular - 在上一个完成后调用行中的过滤器方法

转载 作者:太空狗 更新时间:2023-10-29 17:01:43 25 4
gpt4 key购买 nike

我有一个 primeng turbo-table 组件。我需要在表格上应用多个过滤器。
来 self 打电话的 parent
myTable.doFilter(first_values); myTable.doFilter(second_values);一个接一个

在子(turbo-table)组件上,实际的过滤器应用如下
doFilter(...filter_values...){ this.pTable.filter(...filter_values...); } 问题是在第一个过滤器完成之前应用了第二个过滤器,这导致了意外结果。
上一个过滤器完成后如何调用过滤器。过滤器完成后会发出一个事件,但我找不到利用它的方法。

Parent.ts

     fetchList(searchData) {
this.ratesTable.reset();
this.ratesDataSource = [];
this.programService.fetchList(searchData)
.then(
(response) => {

this.ratesDataSource = response.rates;
this.doTermFilter();
this.doLoanFilter();
})
.catch((error) => {
console.error("from ts" + error);
});
}
doTermFilter(){
this.doFilter({ filterValue: _termFilters, columnField: "COL1", filterMethod: "in" });
}
doLoanFilter(){
this.doFilter({ filterValue: _loanFilters, columnField: "COL7", filterMethod: "in" });
}

child.ts(涡轮表)

     doFilter(doFilterInput: { filterValue: any[], columnField: any, filterMethod: any }) {
this.pTable.filter(doFilterInput.filterValue, doFilterInput.columnField, doFilterInput.filterMethod);
}

非常感谢任何帮助。谢谢

最佳答案

你可以使用 async/await 作为:

    fetchList(searchData) {
this.ratesTable.reset();
this.ratesDataSource = [];
this.programService.fetchList(searchData)
.then(
(response) => {

this.ratesDataSource = response.rates;
await this.doTermFilter();
await this.doLoanFilter();
})
.catch((error) => {
console.error("from ts" + error);
});
}
async doTermFilter(){
this.doFilter({ filterValue: _termFilters, columnField: "COL1", filterMethod: "in" });
}
async doLoanFilter(){
this.doFilter({ filterValue: _loanFilters, columnField: "COL7", filterMethod: "in" });
}

关于angular - 在上一个完成后调用行中的过滤器方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51414927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com