How to use List components in Ireport :

When dragging over a list component to one of the report’s bands, iReport will not prompt you for anything, unlike the process for the table component. You’ll have to configure it once it’s on the design area. Once the List component is in the design area, you can edit the table datasource (by right-clicking on the component).

  • In the “Connection/Datasource Expression” tab, set the drop-down to “Don’t use connection or datasource”

  • In the “Parameters” tab, add a new parameter:

    • Set the “Dataset parameter name” to REPORT_CONNECTION

    • Set its corresponding Value Expression to the parameter containing the database connection statement

Once you have that ready, you will be ready to drag fields, values or parameters for that subdataset over to the List element’s area.

Example :

Lets start with some example to understand more perfectly :

Here my main idea is to create a report with positon and salary range of each employee department.

Step1: create an Employee Report :

1

step 2:

here I selected some fields employee id ,hiredate,fullname,position title and salary as dispayed below.

2

Step 3 :

lets drag and drop list element into footer position of positon group as below, now you can see a dataset1 automatically formed in report inspector and listcomponent as shown below.

3

Step 4:

Now lets add some querie in dataset1 with a parameter positon_id and create the same in parameter list

like below

4

step 5:

Drag and drop the fields from the dateset1 into the list ,dont use the fields from the main dataset.

5

Step 6:

now right click on list(component ) and click Edit list datasource , a pop up will be appeared in use data source expression use connection expression

6

step 7:

select the parameters tab and and map the parameter with the field in main report position id

7

8

step 8:

Run the report to get the desired output

9

This is how we can use lists in ireport..

Thank you.

Leave a Reply