Jump to content

Month Parameter to show previous month by default


sugita

Recommended Posts

I am populating Month1 Parameter as list of 12 months starting from current month. By default I want to list the previous month as default month.
E.g.: If "Mar-2010, Feb-2010.... Apr-2009" is the list of Parameter Value then Feb-2010 should be coming as default value.
I want to show the months in Order and want to avoid the jumbling of values to get previous month on Top as default value.

I am populating it as Single Select Query and taking data from dual table from Oracle Database.

On ireport, I have set the JavaCode for picking the default value for this parameter  and it is working fine on Ireport but while using on JasperServer, it is showing the first month as the default month i.e. Mar-2010.

Please let me know how to get previous month as default on JasperServer.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

sugita,

JasperServer input controls do not have a way to define the default value. This would be a nice enhancement. Add it to the tracker and mention the id number in this thread if it's important for you. I would vote for it.

It will always default to the first value.

So I would solve this by repeating last month twice in the list. The pseudo-SQL would look like this:
SELECT mydates FROM (
SELECT 1 as dummy_column, <last_month> as mydates FROM DUAL
UNION
SELECT 2 as dummy_column, <last_12_months> as mydates FROM DUAL
) combined_queries
ORDER BY dummy_column asc, mydates desc

That gives you a resultset with 13 values. The first is last month. The next 12 are the months in order. Repeating last month shouldn't bother anyone. I didn't code the part for <last_12_months>, but the idea should be clear.

Would that work for you?

Regards,
Matt



Post Edited by mdahlman at 03/23/2010 19:01
Link to comment
Share on other sites

Hi Matt,

Thanks for your response.

It was possible to add the default value pointing to the second element provided it is handled in the ireport. It is not neccessary to always point to the first value. I had already done it with String List of Values but somehow I was getting stuck while implementing it in Month.

However I was successful in resolving this issue. The issue was difference in Case on ireport and JasperServer. e.g.: The Default Date set on ireport was giving value as 'Feb-2010' and on JasperServer getting populated as 'FEB-2010'.
I changed the case on ireport and it started pointing to the previous month by default.

Regards,
Sugita

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