Expand/collapse detail rows in viewer (DrillDown)



We would like to realize a DrillDown functionality in JasperReports. The origin of our JasperReports is CrystalReports.

If the user clicks on a group heading in the viewer, the detail data records should be displayed or hidden. This is what our current solution looks like:

We use an already compiled report. We catch the group heading click with a hyperlink listener. Then a parameter for the display (type: ArrayList) is changed accordingly and the compiled report is completely recreated with an in-memory datasource. The JRViewer panel will be replaced by an updated panel. After that the previously displayed page will be displayed.

Who knows a better solution? Is it possible to optimize the complete rebuilding of the report? Is there a shortcut?

Usually our reports need a relational database. What's the best strategy to get an in-memory datasource? In our first attempt we developed a List/List/Map for the datasources/rows/fields. But it may be possible to get this with a SortField.


Java 8 / Swing / JasperReports 6.0.4 jar

Marcus W's picture
Joined: Nov 7 2017 - 7:32am
Last seen: 4 months 1 week ago

1 Answer:


For the datasource, I usually use a in-memory database such as hsql.

Most times nowadays, I don't use Swing but use html instead.

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 3 weeks ago