Everything works fine now following your example.
Thank you very much for your kind support!
sahl04
@sahl04
Posts made by sahl04
-
RE: How to access the 'data' provided by an API rendering request?
-
RE: How to access the 'data' provided by an API rendering request?
This is the minimal template, very similar to your example but just adding some ifs.
https://playground.jsreport.net/studio/workspace/HkLP_eNqM/2
Perhaps your example works fine from API because there is sample data defined.
-
RE: How to access the 'data' provided by an API rendering request?
Your solution is very close, containing already that what i need!
<script> var dataEl = document.getElementById('data-serialized') var data = JSON.parse(dataEl.innerText); </script>
But there is still an issue.
If i call the template containing this<script> var dataEl = document.getElementById('data-serialized') if(dataEl === undefined) { document.write("dataEl is undefined"); } if(dataEl === null) { document.write("dataEl is null"); } </script>
over API, the document shows 'dataEl is null'.
What is happening now? -
RE: How to access the 'data' provided by an API rendering request?
Exactly, i want to access the data in the template.
I just viewed 'Deep dive into jsreport' on YouTube.
Is this the right approach?<script> var data = []; data.push({{Message}}); </script>
-
How to access the 'data' provided by an API rendering request?
Hi all,
we are just starting with jsreport and facing a problem now.
Currently we are loading (test) data from a local JSON file.
In the next step we like to call the API for the report to be rendered.
Imagine the following body in the API call.{ "template": { "shortid" : "g1PyBkARK" }, "data" : { "Message" : "Hello World!" }, "options": { "timeout": 60000 } }
How can we access the 'data' as a JavaScript object within the report Definition?
Perhaps you can give a link or a short code snippet.
Best regards
Dirk