Calling filter methods in row after the previous is finished
you can use async/await as :
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" }); }
Check out my answer to How to filter complex structured Json data in Angular 6 - I use the rxjs Observable pattern to implement a reactive/functional/declarative solution to filtering a table that I think matches your use case...? (it's difficult to tell without code)
This is filter method source code:
filter(value, field, matchMode) { if(this.filterTimeout) { clearTimeout(this.filterTimeout); } if (!this.isFilterBlank(value)) { this.filters[field] = { value: value, matchMode: matchMode }; } else if (this.filters[field]) { delete this.filters[field]; } this.filterTimeout = setTimeout(() => { this._filter(); this.filterTimeout = null; }, this.filterDelay);}
You can see they are using timeouts and event is emitted only once, because previous timeout gets canceled, but overall situation is not clear without full example.
Link: https://github.com/primefaces/primeng/blob/master/src/app/components/table/table.ts