簡體   English   中英

將列過濾器添加到 Angular 可折疊材料表

[英]Adding column filters to Angular collapsible material table

我正在使用具有可折疊功能的角形材料表。 根據角度材料文檔,我有以下代碼塊。 但它不適用於我的數據源。 有誰知道這有什么問題?

HTML

<mat-form-field>
  <input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>

JS

applyFilter(filterValue: string) {
  this.dataSource.filter = filterValue.trim().toLowerCase();
}

數據格式 (console.log(this.dataSource.data)) 在此處輸入圖片說明

您可能需要定義自定義filterPredicate因為在某些情況下默認實現不會按預期工作。

this.dataSource.filterPredicate = function (data:Element, filter: string){
  // return true if filter string match with the data Element
} 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM