Sometimes we may bump into a requirement of displaying a list value in the Title Bar and it is very tricky situation in Jaspersoft Studio.
Title and Summary Bar will not display a List Value field and if we try to drag and drop a column with No Calculation Function, It will display the first indexed value. Please see the screenshots below to understand the concept.
I created a simple Report and Now when I drag and Drop the SHIPNAME Field into Title and see What happens.
In this case, there two ways to display a list value in the Title or Summary Bar
1) Is by creating a SubReport with required data and place it in the Title Field.
2) is by Adding a List palette and creating a new Dataset.
Using Sub Report Method:
In the above example, I will now display Top 10 Country Name in the title Band using Sub Report.
I have already created a Report with Top 10 Country values and the Value field is added in the detailed section of the sub report.I will just add this report as a Sub Report using the palette. Detailed explanation of creating and using Sub Report will be explained in a different Blog.
Here I added the Sub Report in the title section as follows
Now when we preview the report, This is how the display would be.
So, This is one way to display the List in Title or Summary Band is by using Sub Report.
Using List Method:
Drag and Drop the List Component from the Palette.
Create a New Data Set and Name it as your wish.
Create the Query for the List items to be displayed.
This will create the List component. Place it in the Title Band.
Drag and Drop the field variable from the new Dataset “Fields ” section into the List Component you just created.
Align the Component and Preview.
To Align the ListComponent:
Once you have created the List Component, you need to align it properly so that you can place it anywhere in the Band and it should display the list without space between two Values. For that
1) Right Click on the Component and Select Arrange In Container –> Horizontal Layout
2) This will align the Field to top left corner. Now Drag the Bottom right corner of the Component to fit the Value Field.
3) Now you can place it anywhere in the Band and it will align to the band. as shown below.