1

I have this json data that is gotten from an API end point.

        [{
            "id": 1,
            "style": "A",
            "color": "black",
            "size": "30",
            "quantity": "122.00"
        },
        {
            "id": 2,
            "style": "B",
            "color": "maroon",
            "size": "24",
            "quantity": "48.00"
        },...]

I know I can use array.map() to loop over the data and give me a table with headers 'style','color','size', and 'quantity' with corresponding data rows below.

What I want to do is transform the rendering into this table format as it is more human-readable and a big plus would be to have the cells editable also (e.g. data ties back to state). Specifically, the sizes are in the column headers. How can I do this using either plain react/javascript logic or even better is there a popular React package that has this capability? Currently looking at react-table and react-virtualized but don't have enough experience on these packages to do something complex. Some code would be highly appreciated.

7
  • it is better to use react-datagrid Commented Jul 26, 2018 at 6:04
  • @Harikrishnan thanks for the suggestion. Some code example would be highly appreciated. I'm reading the docs but aside from creating a normal table, not sure how to transform the rendering as in the question. Commented Jul 26, 2018 at 6:10
  • i think there are enough examples available in react-data-grid documentation,if you are stuck at implementing then put another question with the problem you face Commented Jul 26, 2018 at 6:14
  • As you are looking at react-table. this might be useful to you. react-table.js.org/#/story/editable-table Commented Jul 26, 2018 at 6:54
  • @GansPotter thanks for the link. Considering a 'Pivoting & Aggregation' table instead of the format in my picture. I'll just have to think of how to print things nicely. Would you happen to know if its possible to have pivot in the table and have the entries be editable at the same time? Commented Jul 26, 2018 at 7:01

1 Answer 1

1

Here is the image of the table which i created.Hope you are looking for this

enter image description here

And here is the link for the project

https://github.com/AdnanShah/ReactJS-KretaHub-

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.