Multiple Objects in 1 Textbox?

Stimulsoft Reports.JS discussion
Post Reply
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Multiple Objects in 1 Textbox?

Post by ericp »

I was wondering if it's possible to have multiple objects in 1 textbox that are comma separated?

For example, I'm creating an excel report and one of my cells wants to have a list of all of the LocationType in my JSON object. So as opposed to creating a report that has 2 different cells (one of each LocationType). It would be 1 textbox, that lists both LocationTypes at once.

For example: instead of a textbox for "Interchange", and then another for "Point Location", this one textbox will say "Interchange, Point Location"
Attachments
Screen Shot 2024-02-26 at 6.44.52 PM.png
Screen Shot 2024-02-26 at 6.44.52 PM.png (269.92 KiB) Viewed 906 times
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Multiple Objects in 1 Textbox?

Post by Lech Kulikowski »

Hello,

You can use the string the JoinColumnContent function:

JoinColumnContent(object dataSource, string columnName, string delimiter)
Writes all the values of the data source column through the separator as a string.

Thank you.
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Re: Multiple Objects in 1 Textbox?

Post by ericp »

Hi @Lech,

I'm having some difficulty understanding that function. If I want a list of all of the LocationTypes separated by a comma, would my function look like:

JoinColumnContent(Projects_CurrentProjectRevision_LocationDetails.LocationType, "LocationType", ",").
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Multiple Objects in 1 Textbox?

Post by Lech Kulikowski »

Hello,

Should be:
JoinColumnContent(Projects_CurrentProjectRevision_LocationDetails, "LocationType", ",")

Thank you.
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Re: Multiple Objects in 1 Textbox?

Post by ericp »

Hi Lech, I made a simple Sample report just trying to get all of my ProjectIDs, but it does not seem to be working. Could you please assist? Thank you!
Attachments
JoinColumnContent.mrt
(49.64 KiB) Downloaded 70 times
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Multiple Objects in 1 Textbox?

Post by Lech Kulikowski »

Hello,

All expressions in the Text components should be in curly brackets:
{JoinColumnContent(Projects_CurrentProjectRevision, "ClientProjectId", ",")}

Thank you.
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Re: Multiple Objects in 1 Textbox?

Post by ericp »

Hi Lech, thank you for responding. That solution seemed to work for basic databands, but I'm running into issues when I use groupheaderbands. In the screenshot, I know that the first line project CC20130027 has 2 LocationTypes: "N/A" and "Hwy Segment".

I am able to get both of these to show if I use a normal databand, but in this case where I'm trying to create a groupheaderband I am unable to get the values to show. I've linked my mrt file and put the last 2 columns as the testing columns. The reason I'm using a groupheaderband is because I essentially need to put 3 objects worth of data in my JSON onto 1 single line to make a spreadsheet.

Please advise
Attachments
JoinColumnContent Test.mrt
(92.14 KiB) Downloaded 73 times
Screen Shot 2024-03-05 at 1.39.17 PM.png
Screen Shot 2024-03-05 at 1.39.17 PM.png (69.43 KiB) Viewed 841 times
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Multiple Objects in 1 Textbox?

Post by Lech Kulikowski »

Hello,

The JoinColumnContent joins all values from the data source and is not depended on any band.

Thank you.
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Re: Multiple Objects in 1 Textbox?

Post by ericp »

Could you take a look at the MRT file that I attached. I have tried many variations, but unable to get the JoinColumnContent expression to work for Groupheaderbands
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Multiple Objects in 1 Textbox?

Post by Lech Kulikowski »

Hello,

Once again - JoinColumnContent joins all values from the data source, it is not possible to join values only by groups with the JoinColumnContent function.

As a way, you can try to use the Cross-Data component.

Thank you.
Attachments
JoinColumnContent Test.mrt
(103 KiB) Downloaded 73 times
Post Reply