Calling report generator from controller

I’m learning to use the report generator and have a question. Suppose I want to invoke the RG from a button in my code. Furthermore, I already have an active datasource open in my controller that has the data needed for the report. Can I call the report generator directly from my controller? Do I need to re-query the database, or can I use my open datasource to supply the data items?
Thanks
Eric

Hi,

yes you can easily do that. In the docs you’ll find instructions how to call reports from screens:
https://doc.cuba-platform.com/reporting-6.5/run_actions.html

In particular, if you are in an editor, you can call a report like this:


@Inject
private Button reportButton;

@Override
public void init(Map<String, Object> params) {
    reportButton.setAction(new EditorPrintFormAction("report", this, null));
}

The “report” is the name of the report you want to call. It will automatically use the datasource and does not require to set a parameter in the report parameter screen as this can be extracted from the datasource you have in your editor.

Bye
Mario

Thanks for the answer! I should have read the docs more.