Making table from JSON data



  • In the below JSON, I need to make table using values from 'timecardDetails'...How to perform that using {{each}}?

    {
    "_id" : "7008a546-a70b-4c26-a2f0-b7712702f257",
    "totalHours" : 10,
    "personEmail" : "abc@gmail.com",
    "consultantName" : "Support",
    "refDataName" : "10/12/2017",
    "timecardDetails" : [
    {
    "chargeCode" : "Administration",
    "hours" : 5,
    "description" : "OK",
    "id" : 1507809485470.0
    },
    {
    "chargeCode" : "Vacation",
    "hours" : 5,
    "description" : "Done",
    "id" : 1507809485800.0
    }
    ],
    "consultantId" : "Support",
    "recCreBy" : "abc@gmail.com",
    "recCreDate" : "12-Oct-2017 17:28:27",
    "recModBy" : "abc@gmail.com",
    "recModDate" : "12-Oct-2017 17:28:27",
    "clientId" : "BOCE",
    "aspectSource" : "cf56829d-33a6-43d2-be4a-0192ea7cb07c",
    "aspectType" : "Consultant Entry"
    }


  • administrators

    according to your data you can do something like this:

    <table>
    <tr>
      <th>Id</th>
      <th>Charge</th>
      <th>Description</th>
      <th>Hours</th>
    </tr>
    {{#each timecardDetails}}
    <tr>
      <td>{{id}}</td>
      <td>{{chargeCode}}</td>
      <td>{{description}}</td>
      <td>{{hours}}</td>
    </tr>
    {{/each}}
    </table>
    

Log in to reply
 

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