Table data rendering issue
React-table version : 6.5.3
I am trying to render table using sample data below
{
"tableData": [{
"a.status": "closed"
}, {
"a.status": "opened"
}, {
"a.status": "reopened"
}],
"columns": [{
"Header": "Activity Status",
"accessor": "a.status"
}]
}
columns are rendering perfectly but data is not rendering. After long struggle when I change my data like this :
{
"tableData": [{
"a_status": "closed"
}, {
"a_status": "opened"
}, {
"a_status": "reopened"
}],
"columns": [{
"Header": "Activity Status",
"accessor": "a_status"
}]
}
What is the solution, if I want to render with first set of data.
I think you will find that . is interpreted to mean object member access.
So a.status requires a data structure like
{
a: {
status: 'closed'
}
}
@baerrach thanks for your reply...
{ "tableData": [{ "a":{"status": "closed" }}, { "a":{"status": "opened" } }, { "a":{"status": "reopened"} }], "columns": [{ "Header": "Activity Status", "accessor": "a.status" }] }
SO it would work ?
Did you try it?
You have not shown us how your columns are configured. react-table supports dot syntax in the accessor (such as accessor: 'a.status') or you can use a function-based accessor (such as accessor: (row)=>row.a.status. Examples of these are all in the docs.
This is a question of implementation. We invite you to join the slack channel and ask for help there or on stack overflow. Thanks!