qq: is this how I need to do it moving forward? Or is there a patch/fix/alternative way I should look to do this going forward?
well, it depends, I am just showing how to pass the data to the subreport the easy way, based on your data entities, however, this does not mean that it is the approach you should take in production. after all the data entities are used more for testing, because on production you will feed the report with your own data (which is likely to be dynamic and not static like the data entity).
the main question here will be how you will get the data for the subreport, in the example i shared i get it from your data entity, but that is just for testing, in real world you can do either of the following:
- fetch the data for the subreport before you call the render of the subreport, this way you do http request (from the browser) and communicate with your server to get the needed data
or
- when calling the render of the subreport pass an id, your subreport should have a script attached that takes such id from data and uses it to execute an http request to your server (at the
beforeRender
step), then in the script you use the results to populate the report data req.data = <http request results here>
what you choose depends on what looks easier for you, and also if the communication with your server is already secure from the browser, if not then the solution with the script looks better because you can hide the http credentials that your server probably needs to authenticate and return correct response.