How to access to data in a nested structure

Stimulsoft Ultimate discussion
Post Reply
chama9880
Posts: 5
Joined: Mon Sep 23, 2024 10:50 am

How to access to data in a nested structure

Post by chama9880 »

Hi!

I need to create a report which datasource is a JSON that basically is an array of objects (masterElement), and this objects have another nested array of objects (childElement).
Here´s a simplified example of it:

Code: Select all

{
    "masterElement": [
        {
            "type": "Type 001",
            "position": 1,
            "configurable": "EDITABLE",
            "childElement": [
                {
                    "position": 1,
                    "indicator": "Indicator 001",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 2,
                    "indicator": "Indicator 002",
                    "contentType": "Liquid",
                    "containerType": "20ML",
                    "status": "FILLED"
                },
                {
                    "position": 3,
                    "indicator": "Indicator 003",
                    "contentType": "Liquid",
                    "containerType": "20ML",
                    "status": "FILLED"
                },
                {
                    "position": 4,
                    "indicator": "Indicator 004",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 5,
                    "indicator": "Indicator 005",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 6,
                    "indicator": "Indicator 006",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 7,
                    "indicator": "Indicator 007",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 8,
                    "indicator": "Indicator 008",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 9,
                    "indicator": "Indicator 009",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 10,
                    "indicator": "Indicator 010",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 11,
                    "indicator": "Indicator 011",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 12,
                    "indicator": "Indicator 012",
                    "contentType": "Liquid",
                    "containerType": "50ML",
                    "status": "FILLED"
                },
                {
                    "position": 13,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 14,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 15,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 16,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 17,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 18,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 19,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 20,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 21,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 22,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 23,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 24,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "status": "EMPTY"
                }
            ]
        },
        {
            "type": "Type 002",
            "position": 2,
            "configurable": "EDITABLE",
            "childElement": [
                {
                    "position": 1,
                    "indicator": "Value 01",
                    "contentType": "Liquid",
                    "containerType": "20ML",
                    "status": "FILLED"
                },
                {
                    "position": 2,
                    "indicator": "Value 02",
                    "contentType": "Liquid",
                    "containerType": "20ML",
                    "status": "FILLED"
                },
                {
                    "position": 3,
                    "indicator": "Value 03",
                    "contentType": "Liquid",
                    "containerType": "20ML",
                    "status": "FILLED"
                },
                {
                    "position": 4,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "sampleType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 5,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "sampleType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 6,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "sampleType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 7,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "sampleType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 8,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "sampleType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 9,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "sampleType": "",
                    "status": "EMPTY"
                },
                {
                    "position": 10,
                    "indicator": "",
                    "contentType": "",
                    "containerType": "",
                    "sampleType": "",
                    "status": "EMPTY"
                }
            ]
        }
    ]
}
That things is that I'm trying to represent in the report the disposition of this elements and couldn't find a way to do it.
Representing it as Master-Detail structure do the job, but here that we need to do it in a more graphical way (using shapes, specific position for the elements, etc) I don´t know how to do it.

Here´s the structure that I need to represent:
reportStructure.jpg
reportStructure.jpg (261.22 KiB) Viewed 18712 times

As you can see, the childElements have a item indicating a position, the text to show and shape/image that can change base on one of its attributes.

Is there any way to access to the childElement attribute of a masterElement when you´re looping it to access its properties using an expression?
Or should I adapt the JSON structure removing this nested structure to represent it in a report?

Any help would be appreciated.

Thanks in advance.
Last edited by chama9880 on Fri Sep 27, 2024 12:51 pm, edited 1 time in total.
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: How to access to data in a nested structure

Post by Lech Kulikowski »

Hello,

Sorry, we did not exactly understand your question. Could you explain your issue in more detail?

Thank you.
Attachments
Screenshot 2024-09-23 205908.png
Screenshot 2024-09-23 205908.png (92.6 KiB) Viewed 18701 times
chama9880
Posts: 5
Joined: Mon Sep 23, 2024 10:50 am

Re: How to access to data in a nested structure

Post by chama9880 »

Hi,

We would like to go with a report design where we can use shapes (round rectangle with the ovals inside) that visually represents a piece of a machine.
The round rectangle represent the masterElements and the ovals are the childElements; with the structure inside the Data band and assigning the masterElement as Datasource, I can´t find a way to access the childElements.
I know that going with the Master-Detail way like you suggests I can achieve it, but the thing is that we are trying to represent the information in a more graphical way.

My question is: having a Data band with masterElement assigned as Datasource, is it possible to have access to the property childElements from Expression?
Captura de pantalla 2024-09-25 163020.png
Captura de pantalla 2024-09-25 163020.png (174.12 KiB) Viewed 18656 times

Hope it's more clear now, if it's not let me know and I try to rephrase it.

I attach the mrt report for you to check.
Attachments
NestedStructure.mrt
(78.78 KiB) Downloaded 250 times
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: How to access to data in a nested structure

Post by Lech Kulikowski »

Hello,

Unfortunately, no. You need to use the DataBand component to "check" all details records.

In that case, you can modify your detail source, that all current records will in one detail row.

Thank you.
chama9880
Posts: 5
Joined: Mon Sep 23, 2024 10:50 am

Re: How to access to data in a nested structure

Post by chama9880 »

Lech Kulikowski wrote: Thu Sep 26, 2024 7:46 am Hello,

Unfortunately, no. You need to use the DataBand component to "check" all details records.

In that case, you can modify your detail source, that all current records will in one detail row.

Thank you.
I don´t follow you Lech, can you please elaborate and explain me with a little more detail based on the example provided (JSON and .mrt shared)?
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: How to access to data in a nested structure

Post by Lech Kulikowski »

Hello,

Could you provide a sample that shows how should look like a report with sent data from the first post?

Thank you.
chama9880
Posts: 5
Joined: Mon Sep 23, 2024 10:50 am

Re: How to access to data in a nested structure

Post by chama9880 »

Lech Kulikowski wrote: Fri Sep 27, 2024 9:48 am Hello,

Could you provide a sample that shows how should look like a report with sent data from the first post?

Thank you.

Hi Lech,

I updated the data from the first post (adding more values) to represent more clear what we need.
Here's how it should look like:
Positioning MockUp.jpg
Positioning MockUp.jpg (137.1 KiB) Viewed 18566 times

I would like to highlight that most of the elements comes from childElement objects:
  • The amount of childElements reflects the number of items to create inside the rectangle (first page has 24 items, second just 10)
  • childElement.position: the number indicating the position
  • childElement.indicator: the text to show for each element
  • childElement.contentType/containerType/status: the color and the shape of the element inside the circle (purple 50ML, red 20ML)
Thank you for your support!
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: How to access to data in a nested structure

Post by Lech Kulikowski »

Hello,

Please check the sample report in the attachment. For the sample is used CheckBox, but you can use red, blue circle images shown by conditions.

Thank you.
Attachments
ReportSample.mrt
(11.37 KiB) Downloaded 229 times
chama9880
Posts: 5
Joined: Mon Sep 23, 2024 10:50 am

Re: How to access to data in a nested structure

Post by chama9880 »

Lech Kulikowski wrote: Mon Sep 30, 2024 8:11 pm Hello,

Please check the sample report in the attachment. For the sample is used CheckBox, but you can use red, blue circle images shown by conditions.

Thank you.
I'll adapt our design to the solution you gave me in the report attached.
Thank you so much Lech for your help!
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: How to access to data in a nested structure

Post by Lech Kulikowski »

Hello,

You are welcome.
Post Reply