Reputation: 167
I am using PrimeNG Treetable https://www.primefaces.org/primeng/#/treetable
I am not getting data from service ,Below is my code
Html
<p-treeTable [value]="temp">
<ng-template pTemplate="header">
<tr>
<th>Item_No</th>
<th>Description</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData">
<tr>
<td>
<p-treeTableToggler [rowNode]="rowNode"></p-treeTableToggler>
{{rowData.item_no}}
</td>
<td>{{rowData.description}}</td>
</tr>
</ng-template>
ts
temp:any[]
this.partService.GetData().subscribe(
result => {
this.partService.part_content = this.resultData.data
}
for(let nodes of this.partService.part_content){
codeItems.push({
"data": {
item_no:nodes.part_content.item,
description:nodes.part_content.description
}
})
}
this.temp.push({
"data": {
item_no:nodes.part_content.item,
description:nodes.part_content.description
},
"expanded":true,
"children": codeItems
})
In above code I am not getting any data which is coming from service,I am not sure whether anything wrong with [rowNode]
Please help
Upvotes: 0
Views: 2470
Reputation: 31
I was struggling with the same thing. It turns out the documentation on PrimeNG TreeTable was somewhat incorrect. It is using http instead of httpClient when it is developed in Angular 6. With that said, I updated my service to include:
Instead of: this.http.get
Use: this.httpClient.get
Instead of: .then(res => res.json().data);
Use: .then(res => res.data);
Hope that helps!
Upvotes: 2