datatable dynamic column header name

UI Components for React
Post Reply
williamanthony
Posts: 1
Joined: 04 Feb 2020, 09:27

04 Feb 2020, 10:46

for example I have this data from backends:

[{"id":{"displayName":"ItemID","value":"1"},"name":{"displayName":"ItemName","value":"Apple"},"price":{"displayName":"Price","value":1}]

and then in react, I need to configure header with "displayName" from data above

<DataTable value={this.state.item}>
<Column field="id.value" header="id.displayName" />
<Column field="name.value" header="name.displayName" />
<Column field="price.value" header="price.displayName" />
</DataTable>

but the result, header displays "xxxxx.displayName" instead the real display name from the data. I've tried using {id.displayName}, but error occured "id is not defined"

how can I achieve this? Thanks

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: Charlestecak and 19 guests