iReport: Passing parameters from a main report query to a dataset query for a table or list

醉酒当歌 提交于 2019-11-28 23:12:04

To pass the parameters from main report to the table or list datasources in the iReport 3.6.7+, you need to do following steps:

1) create required parameters in the main report by right clicking on the parameters section of main report------> add parameter-------->set the properties (data type) of newly added parameter to your desired one.

2) create equivalent parameters in the table/List's data source's parameters section exactly as in step 1.

3) from report explorer, right click on the table and click on Edit Table DataSet ------> Select the parameters tab ----------->Click on add ---------->Choose the parameter (which you created in the dataset's parameter section in step 1) from upper combo (i.e. Dataset parameter name) ------> then click on lower button (i.e.) assign value expression i.e. the params which you added in step 1.

source : http://hamroblog-sristi.blogspot.fr/2011/04/passing-parameters-from-main-report-to.html

Don't know what version you are using, but I was able to do it in iReport 3.7.6.

First I add the parameters to the dataset.

Then, to pass the values to the parameters, right-click on the Table in Report Inspector, choose "Edit table datasource". Go to "Parameters" tab. Each dataset parameter can take its value from parameter, field, or variable from the main report.

I make a quick test report to replicate what you were doing and it worked.

Here are the steps I took.

  • Create a parameter in your report e.g. customerID

  • Pass it to your main report in a hashmap.

    hashmap.put("customerID", "12345");

  • In the report set the property The language of for the dataset query to SQL.

  • Set the property Query text to something similar as is bellow.

    select * from * customers c where c.ID=$P{customerID}

To pass the parameters from main report to the table or list datasources in the iReport upper version we need to do following steps:

  1. create required parameters in the main report by right clicking on the parameters section of main report------> add parameter-------->set the properties (data type) of newly added parameter to your desired one.
  2. create equivalent parameters in the table/List's data source's parameters section exactly as in step 1.
  3. from report explorer, right click on the table and click on Edit Table DataSet ------> Select the parameters tab ----------->Click on add ---------->Choose the parameter (which you created in the dataset's parameter section in step 2.) from upper combo (i.e. Dataset parameter name) ------> then click on lower button (i.e.) assign value expression i.e. the params which you added in step 1.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!