Dynamic Report based on Dynamic Data



  • Hi,

    My requirement is, the UI will be having a table with number of rows and the user need to enter the value there and after that my application has to capture the data from the table and have to generate the report. Here the issue is if the user adds a new row in the UI I have to add new row in the report. My application is a standalone desktop apllication, here jsreport is running in the backend along with electron and the frontend is angular5.

    As per the following reference I found it is not possible.
    https://forum.jsreport.net/topic/566/javascript-on-a-script-page

    If I am wrong please guide me how to achive this.

    Thanks,
    Bala



  • I'd say that it's not exactly clear what you are after but first question that comes to my mind is why don't you just send the POST request to your template url with all the required data and process the data in the script at 'beforeRender' function.
    So in steps you'd do something like:

    • send a post request with all the required data
    • create a script with beforeRender function that will process the data and set the request.data.youdata object
    • access the data from the template and using the chosen rendering engine loop for the data and generate the report

    If that's not what you are after then please be more specific. Cheers



  • @vajnorcan Thanks for your reply. But what you said is out of my question. Once again I will repeat my question with more information.

    I have a table with 5 rows on the screen, If the use clicks generate report I have to generate report with a table of 5 rows to achieve this I am using <table></table> and <tr></tr> tags manually. In case if the user is adding a new row in the screen using "Add New Row" button and generates the report, then the report should have a table of 6 rows, in this case manual coding will not be helpful. So I was trying to make it automated with javascripts, but jsreport is not supporting the <script></script> tag, so please help how to achieve that.



  • @bala10 , so where do you see manual coding in my answer?

    • when the user clicks generate report, you collect your data on your page into a meaningful object
    • send this object via post request (or even GET would be fine) to the url that is available for your template
    • let the template script (that runs on nodejs) process the data and inject it into request.data parameter
    • in template {{#each my-custom-data}} loop through your data and generate as many rows as necessary

    see the last codepen here https://jsreport.net/learn/live-reports



  • Ohhhh!!! That's really Great!!! @vajnorcan

    Thanks for your quick and valuable guidance.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.