Angular 在不使用管道的材质表中搜索

Angular 在不使用管道的材质表中搜索,angular,angular-material,Angular,Angular Material,在我的物料表中,我使用@pipe获取名称,而不是位置行中的位置 我从另一个JSON文件中获得一个名称 <ng-container matColumnDef="position"> <mat-header-cell *matHeaderCellDef> No. </mat-header-cell> <mat-cell *matCellDef="let element"> {{element.position | FilterD

在我的物料表中,我使用
@pipe
获取名称,而不是位置行中的位置

我从另一个JSON文件中获得一个名称

<ng-container matColumnDef="position">
      <mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.position | FilterData }} </mat-cell>
现在,当我尝试使用角度材质表中的搜索框名称搜索时,没有数据,但如果我输入位置编号,我会正确地得到过滤后的数据

问题可能是因为datatables数据取自组件,但管道更改html中的数据

如何告诉mat表也通过表中的管道数据进行搜索

下面是一个工作示例,尝试按名称(氮、氦等)进行搜索


Thnx

如果您使用的是Material Table,我建议您也使用MatTableDataSource。在typescript的开头声明它,并像加载数组或列表一样加载它的数据

数据源:MatTableDataSource


html


如果您使用的是Material Table,我建议您也使用MatTableDataSource。在typescript的开头声明它,并像加载数组或列表一样加载它的数据

数据源:MatTableDataSource


html


请参考以下URL:

如果你遇到任何困难,请告诉我


谢谢:)

请参考以下URL:

如果你遇到任何困难,请告诉我


谢谢:)

thnx,我已经用过了,因为过滤对表的所有部分都有效,但对于pipe notthnx,我已经用过了,因为过滤对表的所有部分有效,但对于pipe notthnx,我没有用过
@Pipe({
  name: 'FilterData'
})
export class OrdinalPipe implements PipeTransform {

  transform(value: Element): string {
    var data =   ElementTitle.filter(
          ElementTitle => ElementTitle.position === value);  // ElementTitle is second JSON file
          return  data[0].name; 
  }
}
someMethodToLoadData(){
   // get your data
   this.datasource = new MatTableDataSource<any>(data);
}
filterTable (filterValue :string) { 
   this.datasource.filter = filterValue.trim().toLowerCase(); 
}
<mat-form-field>
   <input matInput (keyup)="filterTable($event.target.value)">
</mat-form-field>