mihir_amreli Posted March 17, 2011 Share Posted March 17, 2011 Hello All I have encountered very strange problem while using Sub report in main report. I have a Sub Report with column title and a detail section both of height 20px. when the sub reports record displays on the main report it prints as expected until when it reaches at the bottom of the page. what happened at that time is , sub report prints just column header and left blank space , then again starts on new page with column header and its detail.so, what i want to do is either print the whole sub report on same page or start whole report from new page .I am attaching here the detail section XML.Thank YouMihir Parekh Code:<detail> <band height="20" splitType="Stretch"> <frame> <reportElement x="0" y="0" width="802" height="20"/> <subreport isUsingCache="true" runToBottom="false"> <reportElement x="117" y="0" width="430" height="20" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"> <printWhenExpression><![CDATA[$F{subReportName}.equals( "subReportDemo_subreport1.jasper" )]]></printWhenExpression> </reportElement> <subreportParameter name="salesman"> <subreportParameterExpression><![CDATA[$F{salesman}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="kasar"> <subreportParameterExpression><![CDATA[$F{kasar}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="roundoff"> <subreportParameterExpression><![CDATA[$F{roundOff}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="roundoffSymbol"> <subreportParameterExpression><![CDATA[$F{roundOffSymbol}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="discount"> <subreportParameterExpression><![CDATA[$F{discount}]]></subreportParameterExpression> </subreportParameter> <dataSourceExpression><![CDATA[$F{subReportName}.equals( "subReportDemo_subreport1.jasper" ) ? new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{parti}) : new JREmptyDataSource()]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "/subReportDemo_subreport1.jasper"]]></subreportExpression> </subreport> <textField isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="44" y="0" width="73" height="20"/> <box leftPadding="1"> <pen lineWidth="1.0"/> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression class="java.lang.String"><![CDATA[$F{vNo}]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="626" y="0" width="78" height="20"/> <box leftPadding="1"> <pen lineWidth="1.0"/> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Double"><![CDATA[$F{creditAmount}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="44" height="20"/> <box leftPadding="1"> <pen lineWidth="1.0"/> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression class="java.lang.String"><![CDATA[($F{vDate}.substring(0,$V{caretPosition}.intValue()+1) +$F{vDate}.substring(($V{caretPosition}.intValue()+3),$F{vDate}.length()))]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="548" y="0" width="78" height="20"/> <box leftPadding="1"> <pen lineWidth="1.0"/> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Double"><![CDATA[$F{debitAmount}]]></textFieldExpression> </textField> <subreport runToBottom="false"> <reportElement x="117" y="0" width="430" height="20" isRemoveLineWhenBlank="true"> <printWhenExpression><![CDATA[$F{subReportName}.equals( "paymentSuReport.jasper" )]]></printWhenExpression> </reportElement> <subreportParameter name="kasar"> <subreportParameterExpression><![CDATA[$F{kasar}]]></subreportParameterExpression> </subreportParameter> <dataSourceExpression><![CDATA[$F{subReportName}.equals( "paymentSuReport.jasper" ) ? new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{parti}) : new JREmptyDataSource()]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "\\paymentSuReport.jasper"]]></subreportExpression> </subreport> <subreport> <reportElement x="117" y="0" width="430" height="20" isRemoveLineWhenBlank="true"> <printWhenExpression><![CDATA[$F{subReportName}.equals( "cashSubReport.jasper" )]]></printWhenExpression> </reportElement> <dataSourceExpression><![CDATA[$F{subReportName}.equals( "cashSubReport.jasper" ) ? new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{parti}) : new JREmptyDataSource()]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "/cashSubReport.jasper"]]></subreportExpression> </subreport> <frame> <reportElement x="117" y="0" width="431" height="20"/> <box> <pen lineWidth="1.0"/> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> </frame> </frame> <textField isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="782" y="0" width="20" height="20"/> <box leftPadding="1"> <pen lineWidth="1.0"/> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression class="java.lang.String"><![CDATA[$F{currentBalanceSymbol}]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="704" y="0" width="78" height="20"/> <box leftPadding="1"> <pen lineWidth="1.0"/> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Double"><![CDATA[$F{currentBalance}]]></textFieldExpression> </textField> </band> </detail> Link to comment Share on other sites More sharing options...
ratnakarreddyk Posted March 21, 2011 Share Posted March 21, 2011 You can use splitType = immediate . Try with that. Link to comment Share on other sites More sharing options...
mihir_amreli Posted March 26, 2011 Author Share Posted March 26, 2011 Thank Youfor your reply. it perfectly worked but the type is Prevent not immediate. Code:<band height="20" splitType="Prevent"> Link to comment Share on other sites More sharing options...
jaritadias Posted April 11, 2011 Share Posted April 11, 2011 Hi,Am also facing the same prb and using splitType="Prevent" didnt help me as I dont want the subreport to be generated on the next page.I have attached the screen shot.Please help as this code has to go to production in a few days.Thanks in advance. 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