Loading promt box with parameters in iReport

随声附和 提交于 2019-12-24 07:00:08

问题


I use Jaspersoft iReport for generating reports. For passing parameters we need to enter the values in the prompt box during runtime.

Can we load up the prompt box with values in a field. So that it looks like a drop down list and we can select the value from that list box? Instead of typing the values.

Is it possible??


回答1:


In JasperReport server it can be done easily, you just have to create parameter1 in JasperReport server.

To create a Input control in JasperReport server

  1. Go to Jasper Server and right click on any directory where you want to create input control for parameter1.
  2. Select "Add Resources" then "Input Controls"
  3. Select type (Single select query) if you have values in database.
  4. Parameter name (should be same as in iReport)
  5. and then query to fetch all distinct values for parameter1
  6. Value and visible column will be same column name in database for parameter1 values.

And then just add this parameter in "Controls and Resources" input controls of your report.




回答2:


Actually the list contains the history of last entered values

for example

If you entered

  1. first time => 1
  2. second time => 2
  3. third time => 3

Then the list will contain values "1 , 2 , 3"
And the last entered value will be the default when the prompt window will appear
In our example "3" will be showed at the prompt window

If you want to use your predefined default value and force NOT display the prompt window
You can make it easily
in the parameter properties values

  1. Set "Use as prompt" Unchecked
  2. Enter your predefined default value in "Default Value Expression"



回答3:


In iReport you can simply create parameter and then in SQL SELECT use:

...where field_name = $P{parameter}

Prompt will appear.



来源:https://stackoverflow.com/questions/15239843/loading-promt-box-with-parameters-in-ireport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!