Is there a way to organize the data and show the PRN
entries based on the date
, for instance, when the month is January
? If there is data for machine 1
with assetCode: PRN
, it should be displayed under the header for children. Similarly, if there is data for machine 2
with assetCode: PRN1
, it should be added under the children for the month of January
. If there is no data for machine 1
with assetCode: PRN1
, it should be set to 0
, the same goes for machine 2
as well.
Below is the provided code snippet:
list.component.ts
rowData = [
{
code: "Machine 1",
assetCode: "PRN",
assetCount: 1,
date: "2019-01-18 00:00:00"
},
{
code: "Machine 1",
assetCode: "PRN",
assetCount: 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",
assetCode: "PRN",
assetCount: 1,
date: "2019-01-21 00:00:00"
},
{
code: "Machine 4",
assetCode: "PRN 1",
assetCount: 3,
date: "2019-01-22 00:00:00"
},
{
code: "Machine 5",
assetCode: "PRN 1",
assetCount: 3,
date: "2019-01-23 00:00:00"
}
];
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'
}
]
};
record.children.push(
{
'headerName': 'PRN',
'columnGroupShow': 'open',
'field': 'assetCount'
}
);
this.columnDefs.push(record);
}
How can I achieve a similar layout as shown in the image below?