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.
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 :
here I selected some fields employee id ,hiredate,fullname,position title and salary as dispayed below.
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.
Now lets add some querie in dataset1 with a parameter positon_id and create the same in parameter list
Drag and drop the fields from the dateset1 into the list ,dont use the fields from the main dataset.
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
select the parameters tab and and map the parameter with the field in main report position id
Run the report to get the desired output
This is how we can use lists in ireport..