From my API I get back 2 arrays, one with the column names and one with the data matching those columns.
To use ag-grid I need to match the columns to the properties of a class.
eg: a column call foo and a class with a property called foo:
public columnDefs: Column[] =
[{ field: 'foo', headerName: 'Foo') }];
then I would need a class to match that:
export class Bar { public foo: string; }
Now, the problem, I get back one array with the names of the column and another with the matching data, so I need to create something like this:
x[0] are the columns that need to be properties, x[1] are the values for that property
for (let index = 0; index < x[1].length; index++) {
this.rowData.push({ x[0][index]: x[1][index] });
}
How can this be done?