Table header and field problem from JSON

UI Components for React
Post Reply
Posts: 1
Joined: 03 Aug 2022, 07:37

03 Aug 2022, 07:48

I have a JSON file I need to put into a table. I have inserted the table body but the weird part is the title repeats more times instead of being one time.

0: {dogId: 100, dogBreed: 'Beagles' , dogCountry: 'USA'}

1: {dogId:200, dogBreed: 'GermanSheperd', dogCountry: 'Germany'}

2: {dogId:300, dogBreed:'Dalmation', dogCountry:'Russia'} goes on until 100 index. My goal is to have dogId , dogBreed and dogCountry as headers/title for the table and fill their respective values from the JSON.

{ ((col,index)=>(

field = {Object.values(Object.keys(col)[index]}
header = {Object.keys(col)[index]}


But my code shows , using map function, I get the 3 headers and their values as row, but also another 97 headers with no values in the table. Is there any way to remove the other 97 undefined headers and empty fields from displaying in my table.

Posts: 3247
Joined: 22 Apr 2013, 15:48

05 Aug 2022, 14:29

I would not do what you are doing. Just follow the PrimeReact Showcase examples of how to build a table from JSON rows.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile:
PrimeFaces Elite 11.0.3 / PF Extensions 11.0.3
PrimeReact 8.0.0

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests