1. Description: the company does a background project, which needs to render the list. I use the Table component of ant, but it is required to generate columns, dynamically according to the data. is there any way to dynamically generate the corresponding columns of similar data?
2. Data structure: const schemasMessage = [
{
"code": "011234567890",
"generalInfo": {
"name": "xx",
"shortName": "xx",
"taxPayerType": "xx",
"taxPayerTypeId": "1",
"registeredCapital": 500,
"characterOfEconomy": "xxx",
"characterOfEconomyId": "21"
},
"transaction": {
"bankName": "xx",
"bankAccount": "1234567890",
"bankLocation": {
"province": "xx",
"city": xx",
}
},
"location": {
"province": "",
"city": "",
"district": "",
"street": "xx",
"address": "xx",
"postCode": "01000000"
},
"contacts": [
{
"name": "xx",
"position": "xx"
},
{
"name": "xx",
"position": "xx"
}
],
"marketing": {}
}]
const columns = [
{title:"Code",dataIndex: "code",key:"code",fixed: "left"},
{title: "GeneralInfo",
children:[
{title:"Name",dataIndex: "name",key:"name"},
{title:"shortName",dataIndex: "shortName",key:"shortName"},
]
}, {
title: "Transaction",
children: [{
title: "bankName",
dataIndex: "bankName",
key: "bankName",
},
{ title: "bankAccount",
dataIndex: "bankAccount",
key: "bankAccount",},
{
title: "bankLocation",
children: [{
title: "province",
dataIndex: "province",
key: "province",
}, {
title: "city",
dataIndex: "city",
key: "city",
}],
}],
},
{
title: "contacts",
children: [{
title: "contacts1",
children:[
{title: "Name",
dataIndex: "name",
key: "name",},
{title: "position",
dataIndex: "position",
key: "position",},
]
},{
title: "contacts2",
children:[
{title: "Name",
dataIndex: "name",
key: "name",},
{title: "position",
dataIndex: "position",
key: "position",},
]
}],
}];
how can I achieve this?