Reputation: 1084
after installing the grails export plugin and adding
<r:require module="export"/>
<export:resource />
to my GSP with the final goal to render the containing DiV/table Contents to PDF.
--- There are no classes rendered it is just a due javascript dyamically generated calculation table for a payment process, so the user can print the payment-summary as pdf to his local filesystem before submitting a payment form. ---
adding the Buttonset:
<export:formats formats="['csv', 'excel', 'ods', 'pdf', 'rtf', 'xml']" />
and removing all unused array elements except 'pdf'
in the controller def exportService
was added sucessfully.
in the docs the following example is given:
def list = {
if(!params.max) params.max = 10
if(params?.format && params.format != "html"){
response.contentType = grailsApplication.config.grails.mime.types[params.format]
response.setHeader("Content-disposition", "attachment; filename=books.${params.extension}")
exportService.export(params.format, response.outputStream,Book.list(params), [:], [:])
}
[ bookInstanceList: Book.list( params ) ]
}
and for now i cannot adapt this to my use-case of contents of a table/div. feel free to downvote if this is trivial and then drop a hint for my thinking to solve this.
best regards
Upvotes: 0
Views: 988
Reputation: 15929
The export plugin 'exports' the data you explicitly want. So in the given example a Book.list(params) dataset is fed to the export plugin in order to export it. So i you want to export only a specific div / table on your page you have to feed the export plugin the data you want.
Creating a button on your page that is able to generate the dataset in the controller and feed that dataset to the export plugin would be a solution.
Upvotes: 2