Nested data
See original GitHub issueCan the data passed to ReactTable be nested?
If so, how would I set the car model in the below example to an accessor?
[
{
"name":"John",
"age":30,
"car": {
"model":"Ford",
"color":"green",
}
},
{
"name":"Jane",
"age":34,
"car": {
"model":"Volvo",
"color":"blue",
}
}
]
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Nested data - tidyr
A nested data frame contains a list-column of data frames. It's an alternative way of representing grouped data, that works particularly well when...
Read more >Nested data
A nested data frame is a data frame where one (or more) columns is a list of data frames. You can create simple...
Read more >How to work with Nested Data - Medium
What is Nested Data? ... The address column contains an array of values. The different addresses in the array are the recurring data....
Read more >Analyzing Nested (Clustered) Data | Center for Large ... - UTMB
Most large data sets that can be used for rehabilitation-related research contain data that are inherently 'nested' or 'clustered.' Persons who see the...
Read more >Nested Data Basics - Trifacta Documentation
In the above dataset, the Scores columns have been nested into a single column of values. This column of values is stored in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I spent some time looking for a code example for this, but I could not find any. The documentation for the accessor does not include calling properties of nested objects.
Since i am using typescript, the simple solution did not work for me:
Instead after some reasearch I found this solution :
Hopefully that will save someone else some time 😉
@hundsim I got your reply in a notification but it does not seem to be posted here…
In the above example of data you only need to provide an accessor like
accessor: 'car.model'
to display your data column by column (e.g. name, age, car.model, car.color) or you can use aCell
renderer to get the whole object out of the row and render it any way you like in that single cell.You could also use a function for your accessor as well:
accessor: row=>row.car.model
.I don’t think what you want to do is an “edge case” as you described in your response.
Search for
accessor
in the doco and there are examples there of all three styles (straight variable name, a dotted variable, and a function callback.