augarte Posted June 20, 2011 Share Posted June 20, 2011 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 More sharing options...
augarte Posted June 20, 2011 Author Share Posted June 20, 2011 Up! Help please! I really need this issue to be fixed! Link to comment Share on other sites More sharing options...
idrinkjava Posted June 20, 2011 Share Posted June 20, 2011 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 More sharing options...
augarte Posted June 21, 2011 Author Share Posted June 21, 2011 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 nulland EndDat > '2011/05/01'and EndDat < '2011/05/30'group by AssUsrorder by AssUsrOtherwise, 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 nulland EndDat > '$P!{IniDat}'and EndDat < '$P!{EndDat}'group by AssUsrorder by AssUsrThat'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 More sharing options...
idrinkjava Posted June 21, 2011 Share Posted June 21, 2011 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now