I am trying to create a table with dynamic columns. So there are 3 columns that are constantly there and rest are dynamically generated. for example
var newCol = ["node1","node2","node3"];
Then I need to have a total of 6 columns in the table.
The table needs to look like :
ID TS Node node1 node2 node3
1 ts1 a
2 ts2 a
3 ts3 b
4 ts4 c
5 ts5 a
6 ts6 b
I have arrays like :
var idArray = ["1","2","3","4","5","6"];
var ts = ["ts1","ts2","ts3","ts4","ts5","ts6"];
var node = ["a","a","b","c","a","b"];
var newCol = ["node1","node2","node3"];
So the logic behind the newCol array is that an API call needs to be made for each element in newCol array and results to be displayed. Right now the api is not ready and I am trying to create the skeleton like the table shown above. API would return the response in the following format
Edit :
However, I also need the need the colArray which would have to be in the table. So for example
newCol.forEach(node => {
this.httpClient.get(this.URL1 + node).subscribe(data => {
add the data into a array (create array of array)
});
});
for ex : URL/newCol[0] would return the data for the API would look like :
{
"totalReqCount": 6,
"map": {
"id1": {
"api": "asd",
"tID": "id1",
"processedTimeDuration": "00:00:11"
},
"id2": {
"api": "asdf",
"tID": "id2",
"processedTimeDuration": "00:00:38"
},
"id3": {
"api": "asdfg",
"tID": "id3",
"processedTimeDuration": "00:00:59"
},
"id4": {
"api": "qwe",
"tID": "id4",
"processedTimeDuration": "00:00:25"
},
"id5": {
"api": "qwer",
"tID": "id5",
"processedTimeDuration": "00:00:00"
},
"id6": {
"api": "qwerty",
"tID": "id6",
"processedTimeDuration": "00:00:02"
},
}
The problem statement is to how to populate the data for the columns in column array into the table.
Here is the stackblitz example for the same.
https://stackblitz.com/edit/angular-hsmswb?file=app/table-basic-example.html
Can anyone help with the same. Much appreciated Thanks