1

I have this kind of JSON:

    {
       description: "Some Description",
       child: [{
          description2: "Some Other Description",
          description3: "Another Description"
       }]

    }

And I want to display it on my PrimeNg DataTable, but somehow it always show blank cell.

Here is my column code

    <p-column field="child" header="Child">
      <ng-template let-col let-item="rowData" pTemplate="body" >
        <tr ngFor="let child of item.child">
          <td>
            {{child.description2}}
          </td>
        </tr>
      </ng-template>
    </p-column>

Is there any solution for this?

1 Answer 1

2

I have found my solution after some trials, here is my answer:

    <p-column>
      <ng-template pTemplate="header">Child</ng-template>
      <ng-template let-col let-childs="rowData.child" pTemplate="body" >
        <tr *ngFor="let child of childs">
          <td>{{child.description2}}</td>
        </tr>
      </ng-template>
    </p-column>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.