question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can 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:closed
  • Created 6 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

16reactions
Akirikicommented, May 16, 2021

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:

    accessor: 'car.color'

Instead after some reasearch I found this solution :

    accessor: (originalRow) => {
                return originalRow.car.color;
            },

Hopefully that will save someone else some time 😉

6reactions
gary-menzelcommented, Oct 26, 2017

@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 a Cell 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found