fabridp Posted March 4, 2009 Share Posted March 4, 2009 Hello.I'm building a table report. I grouped this table by the field X and in the group footer I made totals.PRICE GROUP100 1200 1TOTAL 300100 2TOTAL 100______________________________________________________________________________________Now, i want make something different like this:PRICE GROUP100 1200 1100 2 TOTALS TABLEGROUP TOTAL1 3002 100________________________________________________________________________________________How can I do that with Jasper-iReport considering i want to output a list of element PRICE/TOTALS?___________________________________________________________________________DOCUMENT 1PRICE GROUP100 1200 1100 2 TOTALS TABLEGROUP TOTAL1 3002 100 DOCUMENT2 PRICE GROUP100 1100 1200 2 TOTALS TABLEGROUP TOTAL1 2002 200.....___________________________________________________________________________________Thanks in advance.FabrizioPost Edited by Fabrizio Dal Pozzo at 03/05/09 08:46 Link to comment Share on other sites More sharing options...
kchaudhry Posted March 4, 2009 Share Posted March 4, 2009 Have you tried creating a group on the field that defines "DOCUMENTS" and putting the totals in that group footer? Link to comment Share on other sites More sharing options...
fabridp Posted March 5, 2009 Author Share Posted March 5, 2009 I simplified the question but the real case in "code" is effectively different. I create three nested groups DOCUMENT TYPE | -DOCUMENT | -ALIQUOTA Totals are displayed when the value of group "Aliquota" change. Now i display totals between document rows but i don't want it instead summarizing totals in a separate footer table with the format used in unwanted case reported. Link to comment Share on other sites More sharing options...
silvios Posted March 5, 2009 Share Posted March 5, 2009 I suppose Your query looks something likeSELECT x, PRICEfield, GROUPfield FROM sometable WHERE somefield = $P{someparameter}And in group footer of x you want to haveSELECT GROUPfield, SUM(PRICEfield) AS TOTAL FROM sometable WHERE somefield = $P{someparameter} AND x = $F{x} GROUP BY GROUPfieldThat's totally different query, you cannot have two datasources in Jasper... but what you can do is to create subreport that can have it's own query.Just create another report, named for example "YourSubReportName.jrxml".Your subreport should receive all parameters as master report plus parameterfor value of current 'x' (because there is additional AND in where clause).It should have query with GROUP BY clause as I wrote it above.When subreport is finished and compiled, return to master report, drawsubreport object in field 'x' group footer. Fill subreport object propertiesset 'Connection Expression' attribute = $P{REPORT_CONNECTION}set 'Subreport Expression' attribute = "YourSubReportName.jasper"map subreport input parameter with values from master report likeNAME EXPRESSIONsomeparameter $P{someparameter}xparameter $F{x}... or whateverAnd that's it. Link to comment Share on other sites More sharing options...
fabridp Posted March 6, 2009 Author Share Posted March 6, 2009 Many thanks Silvios! You have been exhaustive. Unfortunately I don't have permissions to make direct query on DB. Presently I must use the JRBeanCollectionDataSource to which pass an ArrayList of objects. ------------- JasperDesign jasperDesign = JRXmlLoader.load(JASPER_REPORT_FOLDER + reportFileName + ".jrxml"); JasperCompileManager.compileReportToFile(jasperDesign, JASPER_REPORT_FOLDER + reportFileName + ".jasper"); JRDataSource lJRDataSource = new JRBeanCollectionDataSource(documents); JasperPrint jp = JasperFillManager.fillReport(JASPER_REPORT_FOLDER + reportFileName + ".jasper", null, lJRDataSource); ... ------------- How can I feed subreport in this bean-context?FabrizioPost Edited by Fabrizio Dal Pozzo at 03/06/09 08:33 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