JasperReports: Passing in a list of lists as a datasource

前端 未结 3 651
耶瑟儿~
耶瑟儿~ 2020-12-21 07:03

I need to populate a few subreports with lists of different objects. Basically lets say i have the following:
Subreport on used Vehicles
Subreport on new Vehicles<

3条回答
  •  没有蜡笔的小新
    2020-12-21 08:05

    Ok, then you need create two fields with the Field Class as java.util.List, one for each list (newVehiclesList and usedVehiclesList).

    Put your two SubReports wherever you want and click on each one doing the following steps:

    Change the "Connection type" to "Use a datasource expression" then change the "Data Source Expression" to new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{yourField})

    Done.

    ps: In order to use the fields inside your newVehiclesList and usedVehiclesList you have to create them inside of their own subReports.

提交回复
热议问题