物料设计表渲染错误ERROR TypeError:ctrl._updateTreeValidity不是函数

时间:2020-01-26 23:03:00

标签: angular-material angular8 angular-reactive-forms

当我尝试在反应形式网页中加载物料表时,出现两个错误:

a)错误 TypeError:ctrl._updateTreeValidity 不是函数(我怀疑是主要错误)

b)busProf.html:242 错误错误:找不到带有路径的控件:'DefaultRates-> ConversionRate'

表单显示所有控件的数据,包括默认费率。这两个错误使可编辑列的转换率无法编辑。 任何帮助将不胜感激,因为我似乎被困住了(经过几个小时之后我想管理)

以下是相关代码:

InitbusinessProfile(businessProfile:businessProfile):FormGroup {
//位于单独类中的代码

  this.fg = new FormGroup({
    Id:  new FormControl(businessProfile.Id, Validators.required),
    BusinessProfileId:new FormControl(businessProfile.BusinessProfileId, Validators.required),
    DefaultRates:     new FormArray([])
  });

  let defRates = this.fg.controls['DefaultRates'] as FormArray;
  for (var i = 0; i < businessProfile.DefaultRates.length; i++)
  {
    var item = businessProfile.DefaultRates[i]  as any;
    defRates.controls.push(item as FormArray);
  }
  return this.fg;
}   

// Main class   
form: FormGroup;
dataSource: MatTableDataSource<any>;
get DefaultRates() : any {         
    return this.form.controls['DefaultRates'] as any ; 
}
ngOnInit()
{    
   this.form =  vm.ProfileCtrls.InitbusinessProfile(response);
   this.dataSource = new MatTableDataSource(this.DefaultRates);
}   

<form [formGroup]="form">
   ....
<ng-container formArrayName="DefaultRates">
  <mat-table [dataSource]="DefaultRates.controls" class="mat-elevation-z8">                                   
    <ng-container matColumnDef="CurrencyCodeBu">
      <mat-header-cell *matHeaderCellDef class="cellHdr">Currency</mat-header-cell>
        <mat-cell *matCellDef="let DefaultRates" >{{DefaultRates.CurrencyCode}}</mat-cell>                                 
    </ng-container>
    <ng-container matColumnDef="ConversionRate">
        <mat-header-cell *matHeaderCellDef class="cellHdr">Exchange Rate</mat-header-cell>
        <mat-cell *matCellDef="let DefaultRates" >
          <mat-form-field> 
              <input matInput formControlName="ConversionRate" value={{DefaultRates.ConversionRate}}>
          </mat-form-field>    
        </mat-cell>                                 
    </ng-container>                                                                    
  </mat-table>
</ng-container>

0 个答案:

没有答案