Jump to content

Can't view subreports


augarte

Recommended Posts

Hi,

I'm having a problem when adding subreports to the main report. If I preview each subreport independently in iReport, these are shown correctly without problems. I have added both subreports in the Summary band of my main report and when I execute it is not showing the subreports. The rest of the content is shown correctly except the subreports. Does anybody know why can't I see the subreports? Do I have to add them in another band of my report?

I attach the main report and both subreports.

Any help will be very appreciated.

Thanks in advance,

Aitor

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Aitor,

 

You need to link the master report to the sub reports. Assume this XML tree structure:

 

/document/user/enrollments/enrollment/assignments

 

If I wanted to create a subreport to output the enrollment items I would set the data source of the main report to something like /document/user because I want to access information on the user level. I would then create a new subreport and tell it to use the same data source as the master, ect. You then need to go back to the main report and under the properties for that sub report you need to set the connection type to Use a datasource expression and enter something like the following for that Data Source Expression

 

((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/user/enrollments/enrollment")

 

In the sub report you would then set the root to be enrollment and then select the data items in that enrollment sub level. You want to make sure that they don't have an extension if you want the sub report to loop through like data.

 

I guess the most important thing to remember is that the subreports know where they are in the XML tree because as you go down levels the extensions of the tree overlap. So in the example above the overlapping would look like this.

 

/document/user

/user/enrollments/enrollment

/enrollment/*

Link to comment
Share on other sites

Hi idrinkjava,

First of all thank you for your answer. I have done some test and I think the problem is related to parameters. If the query of the subreport is written without parameters the subreports is shown correctly in the main report:

select AssUsr as DEVELOPER, SUM (TskDoTim) as HOURS, convert(decimal(10,2), '0.00') AS DAYS, convert(decimal(10,2), '0.00') AS WEEKS  from Tsk
where PrtAls like '%ALU%'
and AssUsr is not null
and EndDat > '2011/05/01'
and EndDat < '2011/05/30'
group by AssUsr
order by AssUsr

Otherwise, if I use parameters in the query, nothing is shown where it was supposed to show the subreport. As you can see in the following query I use three parameters which are defined in both, the main report and the subreport. 

select AssUsr as DEVELOPER, SUM (TskDoTim) as HOURS, convert(decimal(10,2), '0.00') AS DAYS, convert(decimal(10,2), '0.00') AS WEEKS  from Tsk
where PrtAls like '%$P!{Prt}%'
and AssUsr is not null
and EndDat > '$P!{IniDat}'
and EndDat < '$P!{EndDat}'
group by AssUsr
order by AssUsr

That's the reason why I think the problem is related to parameters. If I run the subreport giving values to the parameters works OK but if I run the report that contains the subreport giving the same values to this parameters is not showing anything. Any idea?

Link to comment
Share on other sites

I don't believe that you are going to be able to run the subreport and see the resulting data. I know that when I do this iReport says that it can't find the data source. Basically, the sub report is displaying the data that it is passed and cannot find that data without the extension that is passed through the subDataSource parameter.
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...