问题
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
- Go to Jasper Server and right click on any directory where you want to create input control for parameter1.
- Select "Add Resources" then "Input Controls"
- Select type (Single select query) if you have values in database.
- Parameter name (should be same as in iReport)
- and then query to fetch all distinct values for parameter1
- 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
- first time => 1
- second time => 2
- 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
- Set "Use as prompt" Unchecked
- 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