简体   繁体   中英

How to limit a report using Dynamic-jasper plugin in grails?

I'm new to grails.I need to generate reports in pdf or any other format.I have used dynamic-jasper plugin for getting the output in pdf format.I have generated my report using example http://www.grails.org/plugin/dynamic-jasper .

But In that example, report showing all the values that are in database.So i dont want all the values in report.Instead of i need to limit the report. Ie When i search the values(by some sql queries),I'll get ao/p of searched values in a list. So i need the report of searched value list.So please guide me to solve this problem

It sounds like you need to make use of the dataSource property:

dataSource: this is a closure that gets the session and the params passed. Here you hook if you need more complex queries to retrieve data, ie based on request parameters or the logged user in the session, or just to integrate with your services or other plugins like Filter Plugin

Inside the dataSource closure is where your logic should go to limit what is shown in the report(your SQL queries would go here if you were using that). If you scroll down to the salesByStateReport in the "named reports" section on your link you are provided with an example:

dataSource = { session, params ->
        Sale.findAll('from Sale as s where s.branch.state = ? order by branch.name', [params.state])
    }

If you are using entity format, just change 'dataSource = ' to 'dataSource:' in your static reportable map.

This would be called from the URL like this using entity format:

http://localhost:8080/yourAppName/djReport/?entity=yourModelClass&state=yourStateValue

Or like this in name format:

http://localhost:8080/yourAppName/djReport/?report=your report name&state=yourStateValue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM