Jump to content

iReport Parameters


paubarnes

Recommended Posts

I am a new iReport developer.

 

I would like to create parameters referencing the following three columns in a table. I am retrieving the data using SQL script:

 

OnlineAmount,

OfflineAmount,

DonationType (online, offline)

 

How do I create parameters to display (online, offline or both)using iReports.

 

In other words, the users should be able to select from any one of these two options(online, offline) or both?

 

I am not sure if I need to create 1 parameter with three options or three parameters:

 

Any suggessions (including examples) would be greatly

appreciated.

 

thx.

paubarnes

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

paubarnes,

 

I can't quite tell what you're asking. Are you trying to use a parameter to filter what data gets returned from the database? Or do you always return OnlineAmount and OfflineAmount but you want to let the use specify which fields get displayed?

 

You could create 2 boolean parameters: one called Online and one called Offline. The user could set these with a checkbox control. Then you could control which field is displayed using the Print When expression for the fields.

 

Your idea of using a single parameter with 3 allowed options could also work. Either way the idea sounds fine. Write back with more detail if you're encountering a specific problem.

 

Regards,

Matt

Link to comment
Share on other sites

Matt,

 

I would like the user to specify which field gets displayed. The user should select from the filter page – OnlineAmount, OfflineAmount or All (all should displays both online/offline). OnlineAmount and OfflineAmount are both fields from the database. I guess I would need to create a variable/parameter for All. How would display these fields and link them to the actual fields in the database?

 

 

eg:

 

dropdown box or checkbox

 

online

offline

all

 

Please provide me with an example – I am new to iReports.

 

Thanks in advance for your help

 

paubarnes

Link to comment
Share on other sites

You can create one parameter (for example $P{DISPLAY_MODE} set it to BigDecimal type), read all the fields from the db, and selectively display them based on the parameter value. Let's say that the parameter value 0 is for offline, 1 for online and 2 for both; in the fields you want to print if the offline is selected, in "Print when expression" put ($P{DISPLAY_MODE}.intValue()==0 || $P{DISPLAY_MODE}.intValue()==2), and in the fields you want to print if the online is selected put ($P{DISPLAY_MODE}.intValue()==1 || $P{DISPLAY_MODE}.intValue()==2). I hope this helps!

 

Pedja

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...