Jump to content
We've recently updated our Privacy Statement, available here ×

A question about input control of Jasper5.1


di.cao
Go to solution Solved by Thomas Zimmer,

Recommended Posts

Hello everyone,

I have a problem when I'm trying to use the input control to prefilter the reports:

A table has two colomns, 'Count' and 'Date';

the sample data here:

----------------------------------------------------

Count                 |         Date                      |

 

----------------------------------------------------

21                       |         May 10, 2013      |

 

----------------------------------------------------

34                       |         May 11, 2013      |

 

----------------------------------------------------

33                       |         May 12, 2013      |

 

----------------------------------------------------

......

----------------------------------------------------

 

Is there a way to get this by using the input control:

when I click on the report, show me a dialog with three items('latest 7 days records','latest 30 days records','latest 90 days records'), after I make a selection, it will show me what I want?

Thank you very much!

D

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution

you can achive this quite simple with the brand new cool DateRanges in jasperreports:

1. Define a first parameter in your report, which gets the count of days you want to go back. In an input control in jasperserver (if you use that), you can build a combo box selection with a static value list, where the user sees 'latest 7 days records','latest 30 days records','latest 90 days records', but the passed value is an integer.

2. Define a second parameter, which's type is "net.sf.jasperreports.types.date.RelativeDateRange" and initialize it with an expression, usinf the user's selection: "new net.sf.jasperreports.types.date.DateRangeBuilder("DAY-"+$P{selector}).toDateRange()"

Then you can use the second parameter, e.g. in a sql statement by typing ".... WHERE date_colum >= $P{param2}.getStartDate()"

See the attached report to make it more clearly :-)

Cheers, Thomas 

http://www.thomaszimmer.net

Link to comment
Share on other sites

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...