angular - 是否可以将独立过滤器与列过滤器一起使用?
问题描述
我知道我们可以使用没有单个列过滤器的独立过滤器(https://akveo.github.io/ng2-smart-table/#/examples/using-filters)但是可以同时使用两者吗?
我试图实现它但不能。见https://stackblitz.com/edit/angular-2cwakj?file=src%2Fapp%2Ffilter-poc%2Ffilter-poc.component.ts
解决方案
使用以下功能更改您的 onSearch 功能。
onSearch(query: string = '') {
this.source = new LocalDataSource(this.data.filter((obj)=>{
if(obj.id.toString().indexOf(query)>-1 || obj.name.indexOf(query)>-1 ||
obj.username.indexOf(query)>-1 ||obj.email.indexOf(query)>-1 ) return true;
else false;
}))
}
推荐阅读
- php - 在 PHP 中使用 cURL 的 PUT 请求
- typescript - 如何制作可以部署到不同 VPC 的 aws-cdk 应用程序
- javascript - 如何设置已经在 react js 中选择的选择选项?
- javascript - 倒数计时器仅倒计时 1 秒然后停止
- javascript - 无法将模块导入 Node JS
- python - 如何在python中更改语音识别的持续时间以在它不识别任何内容时停止
- python - SpaCy,如何创建一个模式来匹配通过 SpeechRecognition 捕获的字符串?
- reactjs - Django CSRF Cookie 未保存但在请求中发送
- elasticsearch - (ES v7.5.1) 从 GCS 快照存储库加速快照恢复
- python - 计算每组值的连续值和平均/最小/最大时间