Why bother creating the first dataset when using t

2019-08-09 08:10发布

问题:

I've been trying to use Jasper Reports Studio 6.2 and am struggling to understand the Datasets.

I don't understand why I'm asked to create a dataset when I create a new report, then asked to create another new dataset when I add a 'table' object. I don't get the first one... in my mind, the one that's associated with the creation of the 'table' object would have the SQL query, and be the data object. If that's the case, what was the point of creating one at the beginning?

回答1:

The data-source for the report will iterate on the reports detail band

The data-source for the table will iterate the rows on your table.

If you have only a table in the report you can

  • Pass an JREmptyDataSource example new JREmptyDataSource(1), this will show detail band once

or

  • Put the table in for example the summary band and set the attribute whenNoDataType="AllSectionsNoDetail" on the jasperReport tag and then pass no datasource to the fill manager.

Why can both be useful?, the first you use to show data using the normal detail band and the second one you use to show for example a table that sums up data on the summary band