primeng
primeng copied to clipboard
datatable doesn't show the data
Hi to all, I created a simple table to understand PrimeNG library. The problem is that the table creates the correct number of rows but doesn't show the data inside the cells. What is the problem?
export interface User{
username;
name;
surname;
email;
}
export class TabComponent implements OnInit {
users : User[];
constructor() {
this.users= [
{
"username": "Ethel Price",
"name": "female",
"surname": "Johnson, Johnson and Partners, LLC CMP DDC",
"email": "22"
},
{
"username": "Ethel Price",
"name": "female",
"surname": "Johnson, Johnson and Partners, LLC CMP DDC",
"email": "22"
},
{
"username": "Ethel Price",
"name": "female",
"surname": "Johnson, Johnson and Partners, LLC CMP DDC",
"email": "22"
}];
}
<p-dataTable [value]="users" >
<p-column field="Username" header="Username"></p-column>
<p-column field="Name" header="Name"></p-column>
<p-column field="Surname" header="Surname"></p-column>
<p-column field="Email" header="Email"></p-column>
</p-dataTable>
Check your field values in the HTML. It should be the name of the attribute.
<p-column field="username" header="Username"></p-column>
You wrote all of them with Uppercase first letter.
Yes, thank you, a stupid error!
Please use forum in future for cases like these;
https://forum.primefaces.org/viewforum.php?f=35