Jump to content
We've recently updated our Privacy Statement, available here ×
  • Why is the first record missing from my subreport?


    djohnson53
    • Features: Data Sources Version: v5.1, v5.0, v4.8, v4.7, v4.6, v4.5 Product: JasperReports® Library

    This is probably caused by the fact that you pass to your subreport the same data source as the one used by the master report. The data source expression of you subreport would look like this:

    <dataSourceExpression>    $P{REPORT_DATA_SOURCE}</dataSourceExpression>[/code]

    It is highly unlikely you really want to do that, since the subreport will move the record pointer in the data source it receives and thus will "consume" the master report data, making it end abruptly.

    The most common situation where we face this problem is when the master report does not need to iterate on anything, but rather give the data source to one of its subreports.

    Such subreports could be placed on the title band of the master. The master report consumes the first record of the data source before passing it further to its surepbort, hence the observed effect.

    Even in cases like these, when the master report does not actually iterate on anything, but rather passed a data source to its subreport, it is not normal to pass the built-in REPORT_DATA_SOURCE parameter to the subreport as shown above. Instead, the subreport data source should be passed in from the parent application using a user-defined parameter in the master report and not passed in as the data source of the master report itself.

    ...<parameter name="MySubreportDataSource"    class="net.sf.jasperreports.engine.JRDataSource"/>...<subreport>...<dataSourceExpression>  $P{MySubreportDataSource}</dataSourceExpression>...</subreport>[/code]

     


    User Feedback

    Recommended Comments



    Guest
    This is now closed for further comments

×
×
  • Create New...