Here's the format I have:
Code: Select all
{
id: 0,
username: `user`,
role: {
id: 0,
name: 'admin'
},
city: {
id: 0,
name: `city_test`
},
country: {
id: 0,
name: `country_test`
}
}
Code: Select all
<p-dataTable #dataTable [resizableColumns]="true" [value]="datasource" [rows]="10" [rowsPerPageOptions]="[5,10,20]" [paginator]="true"
[pageLinks]="3" [responsive]="true" [rowHover]="true" [rowStyleClass]="onRowRender" [loading]="loading" [lazy]="false" (onLazyLoad)="lazyLoad($event)"
[totalRecords]="totalRecords">
<p-column field="username" header="username" [filter]="true" filterPlaceholder="Search">
</p-column>
<p-column field="role" header="role" [filter]="true" filterPlaceholder="Search" filterMatchMode="in">
<ng-template let-user="rowData" pTemplate="body">
{{user.role.name}}
</ng-template>
</p-column>
<p-column field="city" header="city">
<ng-template let-user="rowData" pTemplate="body">
{{user.city.name}}
</ng-template>
</p-column>
<p-column field="country" header="country">
<ng-template let-user="rowData" pTemplate="body">
{{user.country.name}}
</ng-template>
</p-column>
<p-column header="actions" styleClass="col-button">
<ng-template let-col let-user="rowData" pTemplate="body">
<button type="button" pButton class="ui-button-warning" icon="fa fa-fw fa-pencil-square-o" (click)="editUser(user)"></button>
<button type="button" pButton class="ui-button-danger" icon="fa fa-fw fa-close" (click)="deleteUser(user)"></button>
</ng-template>
</p-column>
</p-dataTable>
Any thoughts?