我有两个组件,Order
和OrderDetail
.
在Order
我有一个MatTableDataSource
,它是从服务中填充的。
订单组件
在建造者之前
listData: MatTableDataSource<DocumentDetailModel>;
displayedColumns: string[]= [ 'row','itemCode', 'itemName', 'priceListCode', 'priceListName',
'wareHouseCode', 'wareHouseName', 'quantity', 'unitValue', 'ivaPercentage', 'valueBeforeIVA',
'totalValue', 'cost', 'stock', 'profitMargin', 'actions'];
@ViewChild(MatSort) sort: MatSort;
@ViewChild(MatPaginator) paginator: MatPaginator;
事件按钮获取
this.service.getDocument(this.service.form.value.documentDate, this.service.form.value.documentType, this.service.form.value.documentNumber).subscribe((data: DataResponseDocumentModel) => {
if(data.code === 1)
{
this.service.form.patchValue(data.documentHeader);
this.service.form.disable();
this.getDataTable(data.lstDocumentDetail);
}
});
功能
getDataTable(lstDocumentDetail) {
this.listData = new MatTableDataSource(lstDocumentDetail);
this.listData.sort = this.sort;
this.listData.paginator = this.paginator;
this.listData.filterPredicate = (data, filter) => {
return this.displayedColumns.some(ele => {
return ele != 'actions' && data[ele].toLowerCase().indexOf(filter) != -1;
});
}
}
从OrderDetailComponent
,我想MatTableDataSource
在它关闭时填写 ,OrderDetail
是MatDialog
。
代码按钮关闭MatDialog
-OrderDetailComponent
onClose(){
this.service.formDetail.reset();
this.service.initializeFormDetailGroup();
this.dialogRef.close();
}
这个应用程序是 Angular 9.1.12