Need output like this. The headers are dynamic and body is not rendering properly. please help me to fix it.
here my code:
{
data?.show &&
<th className="text-center" key={index}>
<td colSpan={data?.st && data.st.length} style={{ border: "none" }}>
{data.label}
</td>
<tr className="p-0">
{
data?.st?.map(sub => {
return (
<td style={{ borderColor: "black" , fontWeight: "400" }}>
{sub}
</td>
)
})
}
</tr>
</th>
}
<tbody>
{
res.datas && res.datas.map((ele, index) => {
var eles = Object.values(ele);
return (
<>
<tr key={index}>
<td align="center">{1 + index}</td>
{
eles.map(dt => {
return (
<td align={typeof (dt)==="string" ? "left" : "center" }>
{dt}
</td>
)
}
)
}
</tr>
</>
)
})
}
</tbody>
But I got output like this.this The expected output is added in the top.