所有人!我使用react,希望json输出count“employees”,如下所示:在这里输入图像描述
[
{
"id": 1,
"departmentName": "Development",
"employees": [
{
"id": 1,
"name": "Max",
"departmentId": 1,
"salary": 20000.0,
"city": "berlin",
"street": "First st.",
"bankName": "bank",
"cardNumber": "de12345678912"
},
{
"id": 2,
"name": "Sam",
"departmentId": 1,
"salary": 20000.0,
"city": "new york",
"street": "Second st.",
"bankName": null,
"cardNumber": null
}
]
},
对于呈现json,我使用datatable
<DataTable value={this.state.departments} paginator={true} rows="25" selectionMode="single"
selection={this.state.selectedDepartment}
onSelectionChange={e => this.setState({selectedDepartment: e.value})}>
<Column field="id" header="ID"/>
<Column field="departmentName" header="Department"/>
</DataTable>
如何为count employees添加字段?
2条答案
按热度按时间byqmnocz1#
如果要使用此datatable(即使它没有column field属性),则可以为其指定selector属性:
bq3bfh9z2#
实际上这很容易