Hi all,
I have a (hopefully) simple question for experienced users.
Basically, how can I pass a custom datasource to a subreport, containing only current record in the main report's data source (which is an XML data source)? That is to say, my report prints invoices. So, in the main report I want to pass a datasource expression to a subreport that holds data only for one invoice, not the whole datasource.
I can pass the whole XML datasource of the main report, but that's not what I want, my idea is to pass only the current record.
Essentially, I have a main report which consist of two detail bands, each having a subreport. I can pass a data source to a subreport using the dataSourceExpression attribute of the subreport element:
where BASIC_DATA_SOURCE is a parameter that holds the value of built-in parameter $P{REPORT_DATA_SOURCE}:
2 Answers:
any ideas, anything? can I use a scriptlet to create a new datasource from the main report's XML datasource and write it to a parameter?
I tried passing the following in subreport datasource expression, but it doesn't work with OpenERP's jasper_reports module which doesn't recognize the expression:
"((net.sf.jasperreports.engine.data.JRXmlDataSource)
$P{REPORT_DATA_SOURCE}).dataSource("/root")"
This is the same issue as mine:
http://community.jaspersoft.com/questions/513715/use-same-jrxmldatasource-multi-subreport
in the 3rd post by CBox it is stated that the solution can be:
"making your own method that returns the datasource with calling the "moveFirst" method before"
in short, how to do that in ireport, by writing a scriptlet and passing the result to a parameter which is used in the subreport's datasource expression?