Jump to content

Choosing more than one value from parameter


markos17

Recommended Posts

I have created document with one parameter id_cycle (cycles names are January, February etc.) I can choose one from 12 cycles and report looks like this:

name value cycle

xyz        123   Jan

yzx        321   Jan

xzy        231   Jan

 

Now, I would like to change it, so I can choose more than one cycle, eg. January, March and July.

CYCLE:    Jan

name   value

xyz        123

yzx        321  

SUM:   444

 

CYCLE: March

name   value

zzz       111

yyy       222

SUM:   333

 

CYCLE: July

name   value

xxx       001

zyz       100

SUM:   101

 

I tried with grouping and cross table. I don't know how to do it, that I can choose more than one cycle (parameter)? What do You think?

 

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

the parameter should be defined as Collection.

If you are using an SQL query, there is a special syntax to deal with collection of value:

SELECT id_cicle, name, value FROM myData where $X{IN, id_cicle, MY_COLLECTION_PARAMETER}

I suffest then to order your data by id_cicle, so you can create groups based on an expression like:

$F{id_cicle}

Giulio

Link to comment
Share on other sites

Thanks for such quick reply! Could You explain me the syntax: $X{IN, id_cicle, MY_COLLECTION_PARAMETER} ? In the first version:

xyz 123 Jan

yzx 321 Jan

xzy 231 Jan

I had such code:

SELECT cycle.cycle, name, value FROM myData WHERE cycle.cyle = $P{id_cycle}

Parameter "id_cycle " had class: "Java.lang.String".  Should I change "id_cycle" Parametr class from "Java.lang.String" to "Java.util.Collection"? What about MY_COLLECTION_PARAMETER? Should I create such parameter? What value does it suppose to have?

I tried with such syntax, but with poor results:

SELECT cycle.cycle, name, value FROM myData

WHERE cycle.cyle = $X{IN, id_cycle, MY_COLLECTION_PARAMETER}

 

and BTW. Are You the author of this book: The Definitive Guide to iReport (Expert's Voice)? :)



Post Edited by markos17 at 07/20/2009 13:32



Post Edited by markos17 at 07/20/2009 13:33
Link to comment
Share on other sites

Parameter:  id_cylce_collection
Type: java.util.Collection
 

SQL query:

SELECT cycle.cycle, name, value FROM myData WHERE $X{ IN, cycle.cyle, id_cylce_collection} order by cycle.cycle

Group expression:
$F{cycle.cycle}

When you pass a value for the parameter id_cylce_collection, it must be of type java.util.Collection (like a List or Vector).

Giulio

Link to comment
Share on other sites

  • 3 months later...

Hi,

Recently, I was generating some reports and have notice some issue. When I use collection parametr, it generates a couple of columns. When there are plenty of them, some of them are moved under the first ones.

Is it possible to display all columns in one level in Excel?

Now, it looks like this:

 

  2009-08-01 2009-08-02 2009-08-03 2009-08-04 2009-08-05 2009-08-06
A 0 0 0 0 0 0
B 0 0 0 0 0 0
  2009-08-07 2009-08-08 SUM      
A 0 0 0      
B 0 0 0      

I'd like to change it into this:

 

  2009-08-01 2009-08-02 2009-08-03 2009-08-04 2009-08-05 2009-08-06 2009-08-07 2009-08-08 SUM
A 0 0 0 0 0 0 0 0 0
B 0 0 0 0 0 0 0 0 0
Link to comment
Share on other sites

Thanks, it works in ireport, but in my application it generates such error:

 

"javax.servlet.ServletException: java.lang.Exception: an error occur during report generation: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'ignoreWidth' is not allowed to appear in element 'crosstab'"

 

Do you think, that I have to do some soft updates?

Link to comment
Share on other sites

  • 1 month 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...