How to access nested object properties in columns
See original GitHub issueHello, I am passing an array of objects in data prop. Those objects in the array have some nested objects. I need to access the nested object properties. How can I do that? Demo data:
const data = [
{
id: 1,
person: {
name: "Bla"
}
},
{
id: 2,
person: {
name: "Lol"
}
}
]
Expected column:
<MUIDataTable
title="Person List"
columns={
[{
name: 'id',
label: 'ID',
options: {
filter: true,
sort: true,
}
},
{
name: 'person.name',
label: 'Person Name',
options: {
filter: true,
sort: false,
},
},
]
}
data={history}
/>
So all I want is to show the person name in column. How can I do that? The person.name
in above code doesn’t work.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How do I render a nested object's property inside an array ...
Consider using ids and mapping to external object data in custom renderers instead e.g. const data = [{"Name": "Joe", "ObjectData": 123}] --> ...
Read more >Accessing a nested object to display as a column i...
I want to display nested properties as columns, too. So where I normally have ThisItem.Property1 for one column, I'd like to do ThisItem....
Read more >Nested object data (objects) - DataTables example
Nested object data (objects). DataTables has the ability to use data from almost any JSON data source through the use of the columns.data...
Read more >Accessing Nested Objects in JavaScript - DEV Community
Array reduce method is very powerful and it can be used to safely access nested objects. const getNestedObject = (nestedObj, pathArr) = ...
Read more >Syntax for nested objects in DataWindow property ...
Nested objects include composite or related nested reports and child DataWindows associated with DropDownDataWindow columns. Related nested and composite ...
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
Hey thanks for all the response. My problem is solved.
I got data like:
I think the only way you have is to flatten your data structure.