combine flat table with compact for pivot data

Answered

Hi, I just downloaded the library and I was reviewing the documentation, and I want to know if it is possible to represent a data table in the following way (I attach an image).
 
since I receive from my api a json with the following format for my data pivots in this case the products of each sale:

{
"id": 1,
"name": "Sales 1",
"date": "2019-02-12",
"seller": "Jhon Doe",
"customer": "Frank Tyler",
"products": [
{ name: "SmartPhone", price: 450},
{ name: "Charger", price: 50}
]
},
{
"id": 2,
"name": "Sales 2",
"date": "2019-02-13",
"seller": "Mill Owen",
"customer": "Paul Bills",
"products": [
{ name: "Tv", price: 800},
{ name: "Laptop", price: 1200}
]
}

then in the documentation did not find an example that works with data in this way, all the examples work with properties of the same parent object. So I wanted to know if it is possible to structure a table like the one of the photo that you attach or something similar? should I check any special part of the documentation? that overlook?

Attachments:
Table.PNG

3 answers

WebDataRocks Team WebDataRocks June 24, 2019

Hello,
Thank you for writing to us.

  1. You can achieve a similar view by using grid.typeclassic. Please refer to our docs for more information: https://www.webdatarocks.com/doc/options-object/.
  2. The suggested JSON format is not supported by WebDataRocks. You will need to convert it into the plain structure by splitting objects with the arrays into several objects.

Regards,
WebDataRocks Team
 

FerCho June 24, 2019

Hello thank you for answering, could you give me an example of how my objects should look to be compatible with WebDataRocks, taking as an example the json that you attach in my question, I would like it very much

WebDataRocks Team WebDataRocks June 27, 2019

Hello,

Thank you for writing to us.

Since WebDataRocks supports a certain kind of JSON data – an array of objects, where each object is an unordered collection of key-value pairs, here is an example of how we suggest modifying your JSON:

		{
            "id": 1,
            "name": "Sales 1",
            "date": "2019-02-12",
            "seller": "Jhon Doe",
            "customer": "Frank Tyler",
            "product_name": "SmartPhone", 
            "price": 450
        },
        {
            "id": 1,
            "name": "Sales 1",
            "date": "2019-02-12",
            "seller": "Jhon Doe",
            "customer": "Frank Tyler",
            "product_name": "Charger", 
            "price": 50
        }

Hope it helps.

Regards,
WebDataRocks Team