DynamicJasper Grails Plugin
Installing the plugin
First you need to install the plugin:
grails install-plugin dynamic-jasper
Using the plugin
Then in those model classes you want to generate reports you have to add the following property:
... def static reportable = true ...
With this 2 easy steps you can start your application:
and point your browser to:
yourModelClass is the artifact name, so the first letter should be lower case.
The previous URL will return you a PDF listing all the instances of yourModelClass.
The columns shown in the report are all the properties in the class except for id and version.
If you desire to customize which columns appear in the report, or their order, just define this property:
def static reportColumns = ['name', 'author.lastName', 'ISBN', 'dateWritten', 'country', 'score']
You can also override this setting by passing a parameter in the query string:
If your entity is related to another entity then the result of toString() will be shown in the report. For instance, in the previous example, the column author will show author.toString()
Besides, you can change the output format adding the parameter reportFormat, for example:
The styles are defined in a file named DynamicJasperConfig. This file is merged with DefaultDynamicJasperConfig (provided with the plugin). If you want to override any style setting defined in the default config file just declare it in DynamicJasperConfig under the conf folder.