Best approach to accessing the data from a template



  • I would like to do some maths, counts, and other interrogation of the data from either template or a js file.
    I am using the JSRender engine in all my reports the example below is using handlebars, when converting to JSRender it fails to work - most likely PEBCAK.

    I found some examples on using scripts etc. the closest I have got was with this.
    https://playground.jsreport.net/w/anon/kntiAOBG
    Which demonstrates one of my simple goals of making a count of the number of items in the JSON.

    My two questions are :

    • Whats the recommended approach?

    • How do you go about referencing the data file for the report?





  • Thanks for the reply. I've had a play with what you suggest but data seems to be nothing???

    My goal is to have a data file for a report and in the template access that data directly.

    From data file...

    {
    "Status": "O",
    "AssetAssessments": [
    {
    "CountOfFindings": 1,
    "EquipmentCompliesWithStandard": "N/A",
    "Findings": [
    {

    In report template

    {{:data.Findings.length}}

    See what I mean ?


Log in to reply
 

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