I have an array as :
result = [
{ 101: {type: "A"},
table: "Employee",
column: "emp_id",
constraint: "unique"
},
{ 101: {type: "B"},
table: "Employee",
column: "emp_id",
constraint: "not_null"
},
{ 101: {type: "B"},
table: "Employee",
column: "name",
constraint: "unique"
},
{ 102: {type: "A"},
table: "Employee",
column: "emp_id",
constraint: "unique"
},
{ 102: {type: "B"},
table: "Employee",
column: "name",
constraint: "unique"
},
{ 103: {type: "B"},
table: "Employee",
column: "emp_id",
constraint: "unique"
},
];
and the columns are dynamic:
columns = [
{Header: "Table", accessor: "table"},
{Header: "Column", accessor: "column"},
{Header: id, accessor: id}
];
So,if there are 5 ids like 101, 102, 103, 104, and 105, then columns will be:
columns = [
{Header: "Table", accessor: "table"},
{Header: "Column", accessor: "column"},
{Header: 101, accessor: 101},
{Header: 102, accessor: 102},
{Header: 103, accessor: 103},
{Header: 104, accessor: 104},
{Header: 105, accessor: 105},
];
I am able to construct the dynamic column headers but unable to construct the rows.
I am trying to show this data in ReactTable like :
Any help would be appreciated!
question from:
https://stackoverflow.com/questions/65923613/how-to-construct-a-final-array-in-javascript