热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何删除在AGGridAngle中为'children'的assetCode的重复项

如何在g网格中删除重复的assetCode或如何mocker.GetMock<IExportJobAdapter>().Setup(x>x.Crea

如何在g网格中删除重复的assetCode或如何mocker.GetMock()
.Setup(x => x.CreateExportJob(It.IsAny()))
.ReturnsAsync(true);
不再重复。
而是PRN和PRN1不断重复...

代码如下:

list.component.ts

assetCode

这是输出:

如何删除在AG Grid Angle中为&#39;children&#39;的assetCode的重复项

在输出上添加新数据时,它添加了ngOnInit() {
this.rowData.push(
{
'code': 'Machine 1','assetCode': 'PRN','assetCount': 1,'date': '2019-01-18 00:00:00'
},{
'code': 'Machine 1','date': '2019-01-19 00:00:00'
},{
'code': 'Machine 2','assetCode': 'PRN 1','assetCount': 3,'date': '2019-01-20 00:00:00'
},{
'code': 'Machine 3','date': '2019-01-21 00:00:00'
},{
'code': 'Machine 4','date': '2019-01-22 00:00:00'
},{
'code': 'Machine 5','date': '2019-01-23 00:00:00'
},);
this.rowData = this.rowData.filter((item: any) => {
return format(item.date,'YYYY') === param;
});
const newData: any = [];
this.rowData.forEach((x: any) => {
const existing = newData.find((y: any) => format(y.date,'YYYY-MM') === format(x.date,'YYYY-MM')
&& y.assetCode === x.assetCode && y.code === x.code);
if (existing) {
console.log(existing);
existing.assetCount += existing.assetCount;
} else {
newData.push(x);
this.rowData = newData;
}
});
this.columnDefs.push(
{
'headerName': 'Style/Machine','field': 'code','pinned': 'left','lockPosition': true
}
);
for (let i = 0; i <12; i++) {
const record = {
'headerName': this.monthNames[i].monthName,'children': [
{
'headerName': 'Total','columnGroupShow': 'closed','field': 'total'
}
]
};
this.rowData.forEach((key: any) => {
if (this.monthNames[i].mOnthName=== format(key.date,'MMMM')) {
record.children.push(
{
'headerName': key.assetCode,'columnGroupShow': 'open','field': 'assetCount'
}
);
}
});
this.columnDefs.push(record);
}
}

输出应仅显示assetCodePRN ....

预先感谢...





推荐阅读
author-avatar
万梅同芳正当时
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有