Jump to content
Changes to the Jaspersoft community edition download ×

List inside a list


aigli.karapostoli

Recommended Posts

Good afternoon. I would like to ask if Jasper supports list inside a list.
Here is an example:
image

In the first list i am using the invoice_id to fetch shipments that involved on this invoice but in the second list

that refers to shipment's cargo details, how can I write in the condition that the shipment_id is the one of the corresponding row?

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Good morning dear, many thanks for your reply. 

 

The thing is that even with the subreport , i have to pass the primary key from the first list (a field), not a parameter from the main query,

 so for each row of the first list, a second list to be generated.

 

If this happens with a subreport, please give me further information on how to parse a field from the 1st list.

 
Link to comment
Share on other sites

Well it's clear that you want to pass the current primary key from the field-value ...

So let's try to describe:

In your MAIN Report (jrxml) you have a SubReport1 (as Element)... at this SubReportElement you define a so called "SubReportParameter" with a name e.g. "TopMostPrimaryKey" and as parameter-expression you define the current field (e.g. $F{YourFieldForPrimaryKeyAtMainLevel} )

In your SubReport (jrxml) you then define a "normal" ReportParameter with the same name (e.g. "TopMostPrimaryKey") and the matching class type (Integer/String/whatever)

in your SubReport (jrxml) query you then can integrate this parameter in your where condition (e.g. WHERE SubTable.ParentKey = $P{TopMostPrimaryKey} )

That's actually all. :-)

So you will now just return the results from  the first Main record + the nested records  with the first primary key... then the SubReport returns and the next record from Main query will be called and the SubReport is also called with the second primary key... and so on....

 

now a bit clearer? 

hth + regards

C-Box

Link to comment
Share on other sites

Hello dear,

indeed subreports seem to be the solution i am searching for, thank you for the instructions.

A quick question:

While the subreport file fetches data (given subtirid = 577 for example) (image1),

the main report show them as null (image 2).

Data Source Expression : new net.sf.jasperreports.engine.JREmptyDataSource()

I am parsing the field to the parameter as you can see on image 3.

 

Thank you in advance.

 

Link to comment
Share on other sites

Ok... so "SUBTIRID" it is on SubReportParameters... and what about the ReportParameter in the SubReport (the sub jrxml) itself? There it must have the SAME name (caseSensitive!) as in the parent SubReportParametersMap..... is this so? Otherwise you could perhaps attach your jrxmls

regards

C-Box

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