'How to display data from different levels inside a nested array in antd table
I want to display data in different levels of the hierarchy in an array in an antd table in react. For example,
{
employees: [
{
id:"II",
firstName: "first name 1",
lastName: "last name 1",
education: [
{
year: "2010",
level: "Bachelors .."
},
{
year: "2013",
level: "Masters"
},
]
},
{
id:"22",
firstName: "first name 2",
lastName: "last name 2",
education: [
{
year: "2010",
level: "Bachelors .."
},
{
year: "2013",
level: "Masters"
},
{
year: "2020",
level: "PHD"
}
]
} ,
{
id:"II",
firstName: "first name 3",
lastName: "last name 3",
education: [
{
year: "2010",
level: "Bachelors .."
},
{
year: "2013",
level: "Masters"
},
{
year: "2020",
level: "PHD"
}
]
}
]
}
in a json like above, if I want to display each education level as a row in the antd table along with other information as follows,
how will I be able to achieve it in antd. Any guidance to solve this will be highly appreciated. Thanks in advance.
Solution 1:[1]
An example is already there in antd documentation https://ant.design/components/table/#components-table-demo-tree-data
Code sandbox example https://codesandbox.io/s/9b6dxf
Key education need to be modified to children and all data related to education year can be inside the child level,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sojin |

