我在对话框中有一个动态表,其中包含自动完成功能和该行的按钮。此按钮添加新行 问题:当我在自动完成功能中选择选项时,我不添加或删除行
@ViewChild('destributedTable') destributedtable: MatTable<any>;
public destributedDataSource:MatTableDataSource<any>;
destributedDisplayedColumns = ["account","percent","control"];
this.destributedDataSource =new MatTableDataSource({account:"","percent:"",control:""});// in constructor
addRowDestributed(event){
let newDectributedAccount=new AccDistributionModel();
this.model.Distribution.push(newDectributedAccount);
this.destributedDataSource.data =this.model.Distribution;
this.destributedtable.renderRows();
}
removeRowDestributed(id:number){
if(this.destributedDataSource.data != undefined){
if(id != 0 || this.destributedDataSource.data.length >1){
this.model.Distribution=this.model.Distribution.filter(function(value, index, arr){ return index != id;});
this.destributedDataSource.data =this.model.Distribution;
this.destributedtable.renderRows();
}
}
}