I receive a JSON object back from my DB
0: {id: 8364, tableId: 137, rowIndex: 0, columnIndex: 0, content: "2015 "}
1: {id: 835, tableId: 137, rowIndex: 0, columnIndex: 1, content: "2016"}
2: {id: 836, tableId: 137, rowIndex: 0, columnIndex: 2, content:"2018"}
3: {id: 837, tableId: 137, rowIndex: 0, columnIndex: 3, content:"2017"}
4: {id: 838, tableId: 137, rowIndex: 0, columnIndex: 4, content:"Change"}
5: {id: 839, tableId: 137, rowIndex: 0, columnIndex: 5, content:"Profit"}
6: {id: 830, tableId: 137, rowIndex: 1, columnIndex: 0, content: "Cash Summary"}
7: {id: 831, tableId: 137, rowIndex: 1, columnIndex: 1, content: "$1200"}
I want to create a HTML table using the data returned.
The data is saved in
const sortedData
How can I use the map function to use the rowIndex and columnIndex to render a table into a react component
In this case the table is 6X6, how do I dynamically set the elements in the even a different size table is returned
Currently I have
let table = sortedData.map((item, i) => {
return (
<table>
<tr key={i} value={item}>
<td>{item.content}</td>
<td>{item.content}</td>
<td>{item.content}</td>
<td>{item.content}</td>
<td>{item.content}</td>
</tr>
</table>
);
});