Angular MatTableDataSource不显示数据,但显示生成的mat单元格

Angular MatTableDataSource不显示数据,但显示生成的mat单元格,angular,angular-material,Angular,Angular Material,我有一张表,包括两列。我想在每个单元格中插入数据,但表中没有任何内容 这是我的html: <div class="example-container" *ngIf="hasResult" style="max-height: 500px;overflow: auto;"> <mat-table [dataSource]="dataSource"> <!-- Progress Column --> <ng-container matC

我有一张表,包括两列。我想在每个单元格中插入数据,但表中没有任何内容

这是我的html:

<div class="example-container" *ngIf="hasResult" style="max-height: 500px;overflow: auto;">
  <mat-table [dataSource]="dataSource">

    <!-- Progress Column -->
    <ng-container matColumnDef="REG_DATE">
      <mat-header-cell *matHeaderCellDef> Date </mat-header-cell>
      <mat-cell *matCellDef="let row"> {{row.REG_DATE}} </mat-cell>
    </ng-container>

    <!-- Progress Column -->
    <ng-container matColumnDef="USE_BYTE">
      <mat-header-cell *matHeaderCellDef> Use byte </mat-header-cell>
      <mat-cell *matCellDef="let row"> {{row.USE_BYTE}} </mat-cell>
    </ng-container>

    <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
    <mat-row *matRowDef="let row; columns: displayedColumns;">
    </mat-row>
  </mat-table>
</div>

日期
{{row.REG_DATE}
使用字节
{{row.USE_BYTE}}

这也是我的ts文件: 当我从同一文件夹中的另一个html中单击search_more()时,数据表将由data.data填充。 我从函数fetch_more()收到了我的数据(数组的25个元素),它工作正常

  search_more(row: any) {
    this.prod_no = row.PROD_NO;
    this.loading = true;
    this.fetch_more((data) => {

      console.log(data.data);

      this.openDialog(data.data);

      this.loading = false;
    });
  }

  openDialog(data): void {
    let dialogRef = this.dialog.open(DetailDialog, {
      width: '500px',
      maxHeight: '600px',
      data: { detail: data }

    });

export class DetailDialog {
  dataSource: MatTableDataSource<any>;
  hasResult = false;
  displayedColumns = ['REG_DATE', 'USE_BYTE'];

  constructor(public dialogRef: MatDialogRef<DetailDialog>, @Inject(MAT_DIALOG_DATA) public data: any) {

    if (data.detail.length > 0) {
      this.hasResult = true;
      const _details = _.orderBy(data.detail, ['REG_DATE']);
      this.dataSource = new MatTableDataSource(_details);

      console.log("DETAILS: " + _details.length);

    } 
    else {
      this.hasResult = false;
    }
  }

  onNoClick(): void {
    this.dialogRef.close();
  }
}
search\u more(行:任意){
this.prod_no=row.prod_no;
这是。加载=真;
这个。获取更多((数据)=>{
console.log(data.data);
这个.openDialog(data.data);
这一点:加载=错误;
});
}
openDialog(数据):无效{
让dialogRef=this.dialog.open(DetailDialog{
宽度:“500px”,
最大高度:“600px”,
数据:{详细信息:数据}
});
导出类详细信息对话框{
数据源:MatTableDataSource

行是空的

我也遇到了同样的问题。经过几个小时的搜索,我发现了以下问题。在显示的列中声明如下:

displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
所以也许你需要做的就是改变

export class DetailDialog {
  ...
  displayedColumns = ['REG_DATE', 'USE_BYTE']; ...


这为我解决了问题。

动态生成的行,但所有这些都是空的。你能创建一个stackblitz/plnkr/JSFIDLE来展示问题吗?我尝试创建演示,但在创建过程中,由于我的组件,我遇到了太多错误。行中有什么?我可以看到它有一些内容我添加了我的行的照片。
export class DetailDialog {
  ...
  displayedColumns: string[] = ['REG_DATE', 'USE_BYTE']; ...