Good afternoon. I would like to ask if Jasper supports list inside a list.
Here is an example:
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?
8 Answers:
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.
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
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.
Thank you once again for your reply.
I have tried all possible combinations, so SUBTIRID --> $F{SUBTIRID}, as you can see on the attached image,
still does not working.
Any other idea?
Attachment | Size |
---|---|
![]() | 6.61 KB |
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